Code:
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#define _CRT_SECURE_NO_WARNINGS
// Displays the list of options available
//prompts for the user’s selection and sets the value of the selection
void mainMenu(int *option);
//Asks the user if they want another transaction
void Keepgoing(char *goagain);
//Asks the user which type of account they _CRT_SECURE_NO_WARNINGS would like to access and sets the
//value of the selection
void AccountMenu( char *acctType);
//Prompts the user for the amount of deposit and updates the selected account
void MakeDeposit( double *balance);
//Prompts the user for the amount of the withdrawal, determines if there are
//sufficient funds and updates the selected account if funds are dispensed
void MakeWithdrawal( double *balance, char acctType);
//Displays the user’s current account balance for the selected account
void GetBalance( double balance);
int main()
{
int choice,
acctType;
char again,
account;
double deposit,
balance,
checking=850.00,
savings=2500.00,
credit=-1850.00;
do{
mainMenu(&choice);
printf("\nChoice entered was %d.\n", choice);
AccountMenu(&account);
printf("\nAccount type selected was %c.\n", account);
/*On your code, everything above this comment is fine.
The if statements below are fine , another option is Switch Case statements.
No matter what order of IF or CASE statements you use, you need a If or Case for the mainMenu,
and another If or Case INSIDE the statements for the AccountMenu
Example:
if (choice == 1)
{
if (account == 'c' || account == 'C')
GetBalance(checking);
}
So inside each of the first IFs (1,2,3) put in secondary IFs (C,S,E)
*/
if (choice == 1)
{
GetBalance(balance);
/*
balance is strictly a place holder used by the function definitions to pass values back to main, it wont give you the true value.
Instead of GetBalance(balance) do GetBalance(checking), GetBalance(savings), or GetBalance(credit)
depending what the user wants to see the value of.
*/
}
if (choice == 2)
{
MakeWithdrawal(&balance, acctType);
}
if (choice == 3)
{
MakeDeposit(&deposit);
}
/*
Stricly a recommendation.
else
{
printf("Your entry was not recognized");
}
*/
Keepgoing(&again);
} while (again == 'y' || again == 'Y');
if(again == 'n')
{
printf("\nThank you. Have a nice day.\n\n",again);
}
return 0;
}
void mainMenu(int *option)
{
printf("Welcome to Regional South Bank.\n\n");
printf("Please choose from the following.\n\n");
printf("1. Check Balance\n");
printf("2. Withdraw Cash\n");
printf("3. Deposit Cash\n");
printf("\nEnter your choice:");
scanf_s("%d",option);
}
void Keepgoing(char *goagain)
{
printf("\nWould you like to do another transcation?\n");
printf("\nChoose y/n:");
scanf_s(" %c",goagain);
}
void AccountMenu(char *acctType)
{
printf("\nWhich account would like to access?\n");
printf("\nC for Checking\n");
printf("\nS for Savings\n");
printf("\nE for Credit\n");
printf("\nChoose an account:");
scanf_s(" %c", acctType);
}
void MakeDeposit(double *balance)
{
printf("\nHow much would you like add:");
scanf_s(" %f", balance);
}
void MakeWithdrawal( double *balance, char acctType)
{
printf("\nHow much would you like to withdraw:");
scanf_s(" %lf", balance);
}
void GetBalance(double balance)
{
printf("\nThe balance is %.2lf.", balance);
}