125k views
2 votes
Write the C program that first prompts the user to input how many customers a bank has. Then, for each customer, the program prompts the user to input the customer's total checking account balance and savings account balance. The program computes and prints the TOTAL amount of money in checking accounts, the TOTAL in savings accounts AND how many customers have MORE money in their checking account than in their savings account.

User MyTwoCents
by
7.1k points

1 Answer

3 votes

Answer:

#include <stdio.h>

int main()

{

int customers, count = 0;

float checking, savings, totalCheching = 0, totalSavings = 0;

printf("How many customers?");

scanf("%d", &customers);

for(int i=0;i<customers;i++){

printf("Enter checking account balance: ");

scanf("%f", &checking);

totalCheching += checking;

printf("Enter savings account balance: ");

scanf("%f", &savings);

totalSavings += savings;

if(checking > savings){

count++;

}

}

printf("Total in checkings: %f \\", totalCheching);

printf("Total in savings: %f \\", totalSavings);

printf("There are %d customers have MORE money in their checking account than in their savings account", count);

return 0;

}

Step-by-step explanation:

Initialize the variables

Get the number of customers from the user

Create a for loop iterates "number of customer" times. Inside the loop, get the checking and saving balance, and calculate their total. If checking is greater than saving, increment count by 1.

When the loop is done, print the totals and count

User Junny
by
6.5k points