Answer to Question #6112 in C++ for margxs

Question #6112
Write a program that reads a customer's account number (int type), account type ( char; s for savings, c for checking), minimum balance that account should maintain, and the current balance. The program should then output the account number, account type, current balance, and an appropriate message. Test you program by running it five times. (TURBO C)
1
Expert's answer
2012-01-27T08:50:55-0500
For TURBO C:


#include <stdio.h>

int main(){

int account_number;
char account_type;
float min_balance, current_balance;
int input = 1;

printf("Input account number:
");
scanf("%d",&account_number);
while(input == 1){
printf("Input account type: 's' for savings, 'c' for checking
");
scanf("%1s", &account_type);
if((account_type == 'c') || (account_type == 's')) input = 0;
else printf("Wrong account type! Repeat, please.
");
}
printf("Input minimum balance:
");
scanf("%f", &min_balance);
printf("Input current balance:
");
scanf("%f", ¤t_balance);

printf("Account number: %d
");
if(account_type == 's')
printf("This account for savings.
");
else
printf("This account for checking.
");
printf("Current balance: %.2f",current_balance);
getchar();

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS