Question: In C program how do I change the input from a numeric number to a character: Let Z =Clear C = Credit D=Debit B =

In C program how do I change the input from a numeric number to a character:

Let

Z =Clear

C = Credit

D=Debit

B = Balance

E = Exit

Also, change how the program exits if the user has input any credits or debits print out the new balance prior to exiting. Unless the last user input already printed the balance as the last command prior to exiting.

#include

int main(void)

{

int cmd;

float balance = 0.0f, credit, debit;

printf("*** ACME checkbook-balancing program *** ");

printf("Commands: 0=clear, 1=credit, 2=debit, ");

printf("3=balance, 4=exit ");

for (;;) {

printf("Enter command: ");

scanf("%d", &cmd);

switch (cmd) {

case 0:

balance = 0.0f;

break;

case 1:

printf("Enter amount of credit: ");

scanf("%f", &credit);

balance += credit;

break;

case 2:

printf("Enter amount of debit: ");

scanf("%f", &debit);

balance -= debit;

break;

case 3:

printf("Current balance: $%.2f ", balance);

break;

case 4:

return 0;

default:

printf("Commands: 0=clear, 1=credit, 2=debit, ");

printf("3=balance, 4=exit ");

break;

}

}

}

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!