Thursday, March 15, 2012

Calculating Credit Limit

Collecting money becomes increasingly difficult during periods of recession, so companies may tighten their credit limits to prevent their accounts receivable(money owed to them) from becoming too large. In response to a prolonged recession, one company has cut it's customers' credit limits in half.Thus, if a particular customer had a credit limit of $2000, it's now $1000.If a customer had a credit limit of $5000, it's now $2500.
Calculate and print new credit limit for each customer.
/*
   title: CreditLimitCalculator
   author: aeriqusyairi
   date: dec272011
*/
#include<stdio.h>
#include<stdlib.h>

int main(){
   int accNum=0;
   float initBalance=0,totalCharge=0,totalCredit=0,creditLimit=0,newBalance=0;
   while(accNum != -1){
      printf("Enter account number(-1 to end): ");
      scanf("%d", &accNum);
      if(accNum == -1)
         break;
      printf("Enter beginning balance: ");
      scanf("%f", &initBalance);
      printf("Enter total charges: ");
      scanf("%f", &totalCharge);
      printf("Enter total credits: ");
      scanf("%f", &totalCredit);
      printf("Enter credit limits: ");
      scanf("%f", &creditLimit);
      newBalance = initBalance + totalCharge - totalCredit;
      if(newBalance > creditLimit){
         printf("Account: %d\nCredit limit: %.2f\nBalance: %.2f\nCredit limit exceeded!\n\n", accNum, creditLimit, newBalance);              
      }else{
         printf("\n");
         continue;      
      } 
   }  
   system("pause");
   return 0;  
}

1 comment:

  1. Hello! So, I have this one assignment here to make the EXACT program as this one. Can I copy your work? I'll make sure that I will learn it too of course. Thanks in advance!

    ReplyDelete