BasedGod -OMG-

Member

Total Posts: 476
Online Status: Offline
Mon Nov 1 19:31:10 EDT 2010

// This program determines if a department-store customer has exceeded the credit limit on a

// charge account by using a sentinel control while loop.

 

#include <iostream>

using namespace std;

#include <iomanip>

 

int main ()

{

       int accountNumber; // customers account number

       double balance; // customers balance

       double charges; // charges on the account

       double credits; // credits to the account

       double limit; // credit limit on the account

       cout << "Enter account number ( -1 to end): " << fixed;

       cin >> accountNumber;

 

      

       while (accountNumber !=-1)

       {

              cout << "Enter beggining balance: ";

cin >> balance;

 

cout << "Enter total charges: ";

cin >> charges;

 

cout << "Enter total credits ";

cin >> credits;

 

cout << "Enter credit limit ";

cin >> limit;

 

double newbalance = (balance + charges - credits);

 

       if (newbalance>limit) // if credit limit exceeds, error message displays

       {

              cout <<"Account: " << accountNumber << endl;

              cout <<"Credit Limit: " << setprecision(2) << fixed << limit << endl;

              cout <<"Balance " << setprecision(2) << fixed << newbalance << endl;

              cout << "Credit Limit Exceeded." << endl;

       }

       cout << "\nEnter account number (-1 to end) : ";

       cin >> accountNumber;

} // end while loop

 

return 0;

 

}





oh my god

Lufia_Maxim

Member

Total Posts: 276
Online Status: Offline
Mon Nov 1 19:47:12 EDT 2010

Are you in Introduction to Programming?

When I took that, we used C++, and did very similar things to you.

If you have trouble with this, you may not want to be programming, btw (smiley)