Ok, here is what I think the finished code is.....any thoughts are welcomed.
felix87871
Code:
#include <stdio.h>
#include <stdlib.h>
main() {
int charge, totalCharge = 0, credit, creditPayment = 0, beginningBal, balance, creditLimit = 500, newBalance, availableCredit, availableCredit1, acctNumber;
acctNumber = 407;
printf("Account number: %i \n", acctNumber);
beginningBal = 250;
printf("Balance at the beginning of the month: %i \n", beginningBal);
printf("Enter a credit charge (-1 to quit):");
scanf_s("%i", &charge);
while (charge != -1) {
totalCharge = totalCharge + charge;
printf("Enter a credit charge (-1 to quit):");
scanf_s("%i", &charge);
}
printf("The sum of the credit charges is: %i\n", totalCharge);
balance = totalCharge + beginningBal;
printf("Balance on credit after charges is: %i\n", balance);
newBalance = beginningBal + totalCharge - creditPayment;
creditLimit = 500;
if (newBalance > creditLimit){
availableCredit1 = 0;
newBalance = beginningBal + totalCharge - creditPayment;
printf("Account number: %i \n", acctNumber);
printf("creditLimit : %i \n", creditLimit);
printf("available credit is: %i \n", availableCredit1);
printf("The new balance is: %i\n", newBalance);
printf("You have exceeded your credit limit! \n");
} else{
availableCredit = creditLimit - newBalance;
printf("Available credit is: %i\n", availableCredit);
printf("Do you wish to continue? \n");
printf("Enter a credit charge (-1 to quit):");
scanf_s("%i", &charge);
while (charge != -1) {
totalCharge = totalCharge + charge;
printf("Enter a credit charge (-1 to quit):");
scanf_s("%i", &charge);
}
}
printf("Enter a credit payment (-1 to quit):");
scanf_s("%i", &credit);
while (credit != -1) {
creditPayment = creditPayment + credit;
printf("Enter a credit payment (-1 to quit):");
scanf_s("%i", &credit);
}
printf("The sum of the credit payments is: %i\n", creditPayment);
newBalance = beginningBal + totalCharge - creditPayment;
printf("The new balance is: %i\n", newBalance);
printf("Do you wish to continue? \n");
system("pause");
}