Question

In this project you will write a C++ program that simulates the purchase of a single...

In this project you will write a C++ program that simulates the purchase

of a single item in an online store.


What to do

Write a C++ program that:

1. Prints out a welcome message.

2. Prompts the user for the following information:
(a) Their first name (example: Roger)

(b) Their last name (example: Waters)

(c) The name of the product (example: Brick)

(d) The unit price of the product (example: 1.99)

(e) The quantity to buy (example: 200)

(f) Their sales tax rate, as a percentage (example: 7.75)

3. Calculates a subtotal, according to the formula

subtotal = (unit price) * (number to buy)

4. Calculates sales tax, according to the formula

sales tax = (subtotal) * (tax rate) / 100

5. Calculates shipping, according to the formula

shipping = .09 * (subtotal)


6. Calculates the grand total, according to the formula

grand total = subtotal + sales tax + shipping


7. Prints out a sales invoice. All of the input data, and calculated dollar amounts, should be printed out (first name, last name, product name, unit price, quantity, sales rate, subtotal, shipping charge, grand total). This information must be printed neatly, with aligned columns, appropriate whitespace, and dollar signs.

For full credit, your program must do the following:

_ declare variables for each of the data items (first name, last name, etc.)

_ use cin to input all the variables

_ store the first name, last name, and product name fields as strings and print them with cout

_ declare double variables for the subtotal, sales tax, shipping, and grand total, assign them values according to the formulas above, and print out the variables to cout

_ use the fixed and setprecision output manipulators to output all dollar figures with only two digits after the decimal point

_ print out all dollar figures in a vertically-aligned column using setw

Sample Input and Output

Hints

Reading strings with spaces

When the << operator reads a string from standard input, it stops at the first whitespace character it encounters. So far you’ve probably used the enter key to designate the end of each data item; but a space will have the same effect. So, if you use cin to read in the string variables, make sure to type in data with only one word (i.e., avoid ”Laser printer”, which has a space). Otherwise your program will get confused.

Rounding to two decimal places

The fixed output manipulator causes the next floating point number printed to cout to use fixed precision mode, meaning that the number of digits after the decimal point is limited according to setprecision. So the following line of code

cout << fixed << setprecision( 3 ) << 3.1415926 << endl;

generates the following output:

3.142

You must #include <iomanip> to have access to these manipulators.

Controlling field width

The setw(k) output manipulator causes the next item to be output to use exactly k characters. If the item would normally use fewer characters, then extra padding spaces are inserted to use up all k characters. Thus

cout << ”Name: ” << setw ( 8 ) << ”David” << endl ;

generates the following output:

Name:   David

Note that there are exactly 3 characters between the : and the D.

You must #include <iomanip> to have access to setw.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
In this project you will write a C++ program that simulates the purchase of a single...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • java; programing language Write a program to calculate the price of a purchase. It should ask...

    java; programing language Write a program to calculate the price of a purchase. It should ask the user to enter the name of the item bought (like sweater, apple, …), number of items bought (4, 5 lbs,…), price per item ($40.50, $1.99 per pound,…), and the sales tax rate (8.35% for example). It should calculate the subtotal (price*number of items), sales tax (subtotal*sales tax), and total price (subtotal+ sales tax). It should print all the information in a receipt form

  • If anyone can make this coded in C++ language. Thank You Lab2 (1) Protected View -...

    If anyone can make this coded in C++ language. Thank You Lab2 (1) Protected View - Saved to this PC w Design Layout ReferencesMailings Review View Help Tell me what you want to do ue: reo.2u Q1. Write a program that will read your initials and five test scores. Your program should then compute your test average and print all information in a reasonable form with suitable messages Note: use two character variables to read input from the user (storing...

  • please I need help with the question: Problem: Write a C++ program that reads each character...

    please I need help with the question: Problem: Write a C++ program that reads each character from a user input, extracts the character if it is a digit, and calculates the sum of all the digits. The program stops reading the user input when the new line character ‘\n’ is encountered. For the output of the program, you should print each digit extracted from the user input and the sum of all the digits. (*The main difference between “cin >>...

  • Write a C++ program that will calculate the total amount of money for book sales at...

    Write a C++ program that will calculate the total amount of money for book sales at an online store. For each sale, your program should ask the number of books sold and then the price for each book and the shipping method (‘S’ for standard shipping and ‘E’ for expedited shipping). The program will produce a bill showing the subtotal, the sales tax, the discount, the shipping charge, and the final total for the sale. The program will continue processing...

  • The objective of this project is to provide experience working with user interface menus and programmed...

    The objective of this project is to provide experience working with user interface menus and programmed decision making. Modify the C++ source you created in Project # 2 to incorporate the following requirements: 1. Present a menu to the user which includes: a. Enter checking account transaction b. Enter savings account transaction c. Quit 2. If the user selects a., request the checking account balance, the checking account transaction date, the checking account description, and the checking account amount from...

  • Need help with a C++ problem I have

    For my assignment I have to write a program that creates a restaurant billing system. I think that I got it correct but it says that it is incorrect, so I was wondering if someone would be able to look over my code. It says that I need tax of $0.20, and the amount due to be $4.10, which is what I have in my output.https://imgur.com/a/jgglmvWMy issue is that I have the correct outcome when I run my program but...

  • Java I: Create a Java program that will accept the price of an item and the...

    Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...

  • write a program in C Write a program to implement the following requirement: The program will...

    write a program in C Write a program to implement the following requirement: The program will read from standard input any text up to 10, 900, characters and store each unique word (any string that does not contain any whitespace) into a node of a linked list, following the following Node struct: struct NODE { char *word; struct NODE * prev; Note that each node must store a unique word, i.e., no word is stored in more than one node....

  • C++ please help thank you so much the results Prog ram Overview: This program will calculate...

    C++ please help thank you so much the results Prog ram Overview: This program will calculate and output ordering products from a vendor. This will include calculating the price for each item ordered, adding sales tax, and outputting the results in a nicely formatted table. Relevant Details and Formulas: Fireworks for sale: $12.99 Red Dragons Blue Chrysanthemums $14.99 Vermilion Lotuses $19.49 el14414, Yo Sparkler Boxes $4.25S s S 21 25 $11144 Sales Tax: 8.1% applied to all purchases Subtotal =...

  • C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you...

    C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you can. Level 1: (20 points) Write FUNCTIONS for each of the following: a) Validate #students, #scores. b) Compute letter grade based on average. c) Display student letter grade. d) Display course average. Level 2: (15 points) Use ARRAYS for each of the following. e) Read a student's scores into array. f) Calculate the student's average based on scores in array. g) Display the student's...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT