Question: It should be coded in c++ For this assignment, there are several parts. Make sure to identify each part in your code with comments (example:
It should be coded in c++
For this assignment, there are several parts. Make sure to identify each part in your code with comments (example: // PART 1). Display the part to the screen as well, and skip lines between each part for readability (example: cout << " PART 2 ";)
Display a "hello" message, then skip a line.
PART 1
- Prompt for the user's full (first and last) name and store it in a variable
- Echo the response
- NOTE: string variables need the < string > header file
- NOTE: Use getline() instead of cin when reading strings
PART 2
- Prompt the user for two integers and store them in variables
- Add the two numbers and store the result in another variable
- Display the expression and result (example: user inputs 8 and 4, display 8 + 4 = 12)
- Using the same two integers (i.e. don't prompt for new values), calculate and display the subtraction expression (example: 8 - 4 = 4)
- NOTE: Do not assume the two integers are 8 and 4, the user could enter ANY integer (positive, negative, or zero)
PART 3
- Prompt the user for an integer number of seconds and store it in a variable
- Display the equivalent number of hours, minutes, and seconds
- Example: 9999 seconds is 2 hours, 46 minutes, and 39 seconds.
- NOTE: There are 3600 seconds in an hour, 60 minutes in an hour, and 60 seconds in a minute.
- NOTE: With integer division (int/int), / will give a whole number and % will give the remainder
- NOTE: Do not assume the time is 9999 seconds, or the result will be 2 hours, 46 minutes, and 39 seconds.
PART 4
- Prompt the user for an item price (example: How much does the first item cost? ) and store in a decimal variable
- Prompt the user for another item price and store it in a decimal variable
- Calculate and display in a table the after-tax price of both items for 6%, 7%, and 8% sales tax
- Include a header row (this is just a simple cout with no variables, headers can be right-aligned instead of centered)
- Include a separator line (another simple cout)
- Show 2 decimal places for all prices
- Column 1 width should be 6
- Columns 2, 3, 4, and 5 widths should be 10
- NOTE: To get the after-tax price at 6%, multiply the price by 1.06 (example: if price is $10.00, then after-tax at 6% is $10.60)
- NOTE: Do not assume prices and after-tax values will be as shown above (user will enter their own prices)
- NOTE: It is not necessary to store expression results in a variable before using them --- the expression can be part of the cout statement!
- Example: cout << "Area is " << (length * width) << endl;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
