Question: In this C Program, I am trying to pass the variable and when I type in item 5 from the main menu I get a

In this C Program, I am trying to pass the variable and when I type in item 5 from the main menu I get a display giving me a $0 balance for both accounts but it should to pass on the balance from the previous screen.

This is my code:

#include

#include

#include

#include

#include

int program();

char exit();

void number1();

int number2();

int number3();

int number4();

void number5();

void number6();

void contProgram();

int a3 = 0; //checking

int b3 = 0; //savings

int c3 = 0; //transfer

int d3 = 0; //new checking

int e3 = 0; //new savings

int main()

{

char stay = ' ';

do

{

system("cls");

program();

printf(" ");

printf("Would you like to make another transaction?");

printf("Y/N: ");

std::cin >> stay;

if (stay == 'y' && stay == 'Y')

{

system("cls");

}

if (stay == 'n' && stay == 'n')

{

system("cls");

}

} while (stay != 'n' && stay != 'N');

return 0;

}

int program()

{

int selection1;

printf("1. Create New Account ");

printf("2. Cash Deposit ");

printf("3. Cash Withdrawal ");

printf("4. Fund Transfer ");

printf("5. Account Information ");

printf("6. Transaction Information ");

printf("7. Exit ");

printf("Press a choice between the range of [1-7]: ");

scanf_s("%d", &selection1);

printf(" ");

system("cls");

switch (selection1)

{

case 1:

printf("1. Here is where you would add an account ");

number1();

break;

case 2:

printf("2. Here is where you deposit money ");

number2();

break;

case 3:

printf("3. Here is where you withdraw funds ");

number3();

break;

case 4:

printf("4. Here is where you transfer funds ");

number4();

break;

case 5:

printf("5. This is your account information ");

number5();

break;

case 6:

printf("6. This is your transaction information ");

number6();

break;

case 7:

printf("7. You have selected to exit? ");

break;

default:

break;

}

if (selection1>7 || selection1 == 0)

{

printf("Your input is out of range! Enter a choice between 1 to 7! ");

contProgram();

}

return selection1;

}

char exit()

{

system("cls");

char exitProgram;

exitProgram = 'Y';

contProgram();

return exitProgram;

}

void number1()

{

system("cls");

printf("Adding new accounts is not possible at this time: ");

contProgram();

}

int number2()

{

system("cls");

int x = 0;

int y = 0;

int z = 0;

printf("Enter the current account balance: ");

scanf_s("%d", &x);

printf(" ");

printf("Enter the amount to deposit: ");

scanf_s("%d", &y);

printf(" ");

z = x + y;

printf("The new balance is: $ %d ", z);

contProgram();

return z;

}

int number3()

{

system("cls");

int a2 = 0;

int b2 = 0;

int c2 = 0;

printf("Enter the current account balance: ");

scanf_s("%d", &a2);

printf(" ");

printf("Enter the amount to withdraw: ");

scanf_s("%d", &b2);

printf(" ");

c2 = a2 - b2;

printf("The new balance is: $ %d ", c2);

contProgram();

return c2;

}

int number4()

{

system("cls");

printf("Enter the current checking account balance: ");

scanf_s("%d", &a3);

printf(" ");

printf("Enter the current savings account balance: ");

scanf_s("%d", &b3);

printf(" ");

printf("Enter the amount to be transferred: ");

scanf_s("%d", &c3);

printf(" ");

d3 = a3 - b3;

printf("The new checking account balance is: $ %d", d3);

printf(" ");

e3 = b3 + c3;

printf("The new savings account balance is: $ %d", e3);

printf(" ");

contProgram();

return c3;

}

void number5()

{

system("cls");

printf(" The current Savings Account Balance is $%d", d3);

printf(" The current Checking Account Balance is $%d", e3);

contProgram();

}

void number6()

{

system("cls");

printf("There is no transaction history available at this time! ");

contProgram();

}

void contProgram()

{

printf(" \t Press any key to continue... ");

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!