Help with Hw
-
dễ muh
change cái comment into code thôi
-
code??? >.<
-
//TASK ONE: DECLARE A VARIABLE CALLED balance OF TYPE float.
float balance;
//TASK TWO: WRITE STATEMENT TO READ KEYBOARD INFORMATION AND
//STORE VALUE IN THE VARIABLE balance.
cin >> balance
//TASK THREE: COMPLETE while SO THAT THE
//LOOP IS ENTERED ONLY IF
//balance IS NOT EQUAL TO -1.
while (balance != -1)
{
...
}
keep on working

April 8th 2009, 3:11 pm
Có ai help kyo với cái C++ lab này được kô vậy??? Plz thkx very much
Bửa đó ham chơi nên miss cái class này
Complete the development of the C++ program that will determine if a department store customer has exceeded the credit limit on a charge account. For each customer, the following facts will be gathered from the user:
+Balance at the beginning of the month
+Total charges for the month
+Total credits (payments) applied for the month
+Allowed credit limit
The program should update the balance and report the new value of balance and "Credit Limit Exceeded" if the new balance exceeds the credit limit.
The program loops requesting new information until the user enters the value -1 to signal the end of data. A running program would generate output similar to the following.
Enter beginning balance (-1 to end): 5394.78
Enter total charges: 1000.00
Enter total credits: 500.00 Enter credit limit: 5500.00
New balance: 5894.78 Credit Limit Exceeded.
Enter beginning balance (-1 to end): 1000.00
Enter total charges: 123.45
Enter total credits: 321.00
Enter credit limit: 1500.00
New balance: 802.45
Enter beginning balance (-1 to end): -1
The code below has several lines of code missing or incomplete. Find the lines that have task comments and replace them with the correct C++ statements so the program would run as indicated above. Note: You will not be entering and compiling this program and there is only one variable used to hold the value of balance.
//CREDIT CARD PROGRAM
#include
using namespace std;
int main()
{
//TASK ONE: DECLARE A VARIABLE CALLED balance OF TYPE float.
float charges;
float credits;
float creditLimit;
char pause;
cout << "Enter beginning balance (use -1 to end):";
//TASK TWO: WRITE STATEMENT TO READ KEYBOARD INFORMATION AND
//STORE VALUE IN THE VARIABLE balance.
while ( ) //TASK THREE: COMPLETE while SO THAT THE
//LOOP IS ENTERED ONLY IF
//balance IS NOT EQUAL TO -1.
{
cout << "Enter total charges: ";
cin >> charges;
cout << "Enter total credits: ";
cin >> credits;
cout << "Enter credit limit: ";
cin >> creditLimit;
balance = //TASK FOUR: COMPLETE ASSIGNMENT TO CALCULATE
//THE NEW balance BASED ON charges AND credits.
//TASK FIVE: WRITE THE STATEMENT TO DISPLAY THE MESSAGE
//"New balance: " AND THE CURRENT VALUE OF balance.
if ( ) //TASK SIX: COMPLETE if SO THAT
//THE if-SECTION IS EXECUTED
//ONLY IF CURRENT balance EXCEEDS
//THE creditLimit.
{
//TASK SEVEN: WRITE STATEMENT TO DISPLAY THE
//MESSAGE "Credit Limit Exceeded.".
}
cout << "Enter beginning balance (use -1 to end):";
cin >> balance;
}
cout << "Press 'Enter' to quit.";
cin.get(pause);
return 0;
}