Simple Expressions 7

Description

Using basic expressions, calculate and display values with input provided by the user.

In this exercise, we are simulating a credit card and how its various numbers are calculated

Requirements

  1. Add another #include line for <iomanip>. This additional line provides support for rounding and number precision.
    #include <iostream>
    #include <iomanip>
    
  2. Declare a double called limit.
  3. Declare a double called balance
  4. Declare a double called usage
  5. Declare a double called trans
  6. Declare 2 doubles called new_bal, new_usage. Declare both of these variables on the same line
  7. Add this line of code after all your variable declarations. Type it exactly as below. This line of code is used for formatting numbers with decimal places.
    cout << fixed << setprecision(1);
  8. Use cin to ask the user to enter a value for limit. See the Sample Interaction below on what message you will display to the user
  9. This is a good point to stop and do a test compile. If you run your program at this point, nothing will be displayed yet.
  10. After your test compile, fix any errors you may have encountered. Continue below once you fix any errors you had.
  11. Ask the user to enter a value for balance. See the Sample Interaction below on what message you will display to the user
  12. On one line, write an expression to calculate the utilization rate and store (assign) this value in usage. Utilization rate is simply the percentage of the balance against the limit.
    usage = **write the expression here**
    
  13. Display a message with the calculated utilization rate (usage) expressed as a percentage. See Sample Interaction below.
  14. Ask the user to enter a value for trans. See the Sample Interaction below on what message you will display to the user
  15. Write an expression to calculate the new balance accounting for trans. Store the result of the calculation in new_bal
    new_bal = balance + trans;
  16. Write an expression to calculate new_usage, similar to how you calculated new_bal above. Make sure to use the new balance against limit when calculating new_usage. 
  17. Display the new balance and utilization rate (See Sample Interaction)

DO NOT USE

You may not use any conditional constructs such as the IF statement

Sample Interaction / Output

Enter credit card limit: 5000
Enter current balance: 2500
Your utilization rate is 50.0%

How much is your new transaction? 350
Your new balance is $2850
Your utilization rate is now 57.0%

LEGEND
PROGRAM OUTPUT
USER ENTRY
FROM INPUT

CATALOG ID: CPP-EXP0007

Print Requirements