83.1k views
2 votes
Develop a script that will determine whether a department-store customer has exceeded the Credit limit on a charge account. For each customer, the following facts are available:

a) Account number
b) Balance at the beginning of the month
c) Total of all items charged by this customer this month
d) Total of all credits applied to this customer's account this month
e) Allowed credit limit The script should input each of these facts from a prompt dialog as an integer, calculate the new balance (= beginning balance + charges – credits), display the new balance and determine whether the new balance exceeds the customer’s credit limit. For customers whose credit limit is exceeded, the script should output HTML5 text that displays the message "Credit limit exceeded."

User Thinkhy
by
5.1k points

1 Answer

1 vote

Answer:

See explaination

Step-by-step explanation:

#include <stdio.h>

#include <stdbool.h>

int main()

{

// Customer account number

int accountNumber;

// Customer parameters

float beginningBalance, totalCharges, totalCredits, creditLimit, accountBalance;

while(true)

{

printf( "Enter account number ( -1 to end ): " );

scanf( "%d", &accountNumber );

if ( accountNumber == -1 )

{

return 0;

}

printf( "Enter beginning balance: " );

scanf( "%f", &beginningBalance );

printf( "Enter total charges: " );

scanf( "%f", &totalCharges );

printf( "Enter total credits: " );

scanf( "%f", &totalCredits );

printf( "Enter credit limit: " );

scanf( "%f", &creditLimit );

accountBalance = beginningBalance + totalCharges - totalCredits;

if ( accountBalance > creditLimit )

{

printf( "Account:\t%d\\", accountNumber );

printf( "Credit Limit:\t%.2f\\", creditLimit );

printf( "Balance:\t%.2f\\", accountBalance );

printf( "Credit limit exceeded.\\" );

}

}

return 0;

}

User GeRyCh
by
5.1k points