Question

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 next book sale until the number of books sold is zero.

Sales tax is calculated on the subtotal and is 5%. The discount is also calculated on the subtotal. The store offers no discount if the subtotal is less than $50, 10% discount if subtotal if $50-$100, and 15% discount if the subtotal is above $100. The store will charge $4.99 for standard shipping and $12.99 for expedited shipping.

program must be done as simple as possible doesnt need to be fancy

A sample output of the program should look like follows.

> ./a.out

Book Sale calculator

----------------------------

Enter the number of books in the sale: 5

Enter price: 2.99

Enter price: 12.45

Enter price: 13.23

Enter price: 21.99

Enter price: 24.59

Enter shipping method [S]Standard shipping [E]Expedited shipping: S

Subtotal:               $75.25

Tax:                        $3.76

Discount:               $7.53

Shipping:               $4.99

Total:                     $76.48

Enter the number of books in the sale: ….

Also use the following data to test your program:

  • 3 books, $8.99 $12.45 $7.58, Expedited shipping

Subtotal:              $29.02

Tax:                     $1.45

Discount:             $0.00

Shipping:             $12.99

Total:                   $43.46

  • 7 books, $5.66 $12.35 $23.56 $40.00 $12.99 $16.32 $11.23, Standard shipping

Subtotal:               $122.11

Tax:                        $6.11

Discount:              $18.32

Shipping:              $4.99

Total:                     $114.89

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is code:

#include <iostream>

#include <iomanip> // std::setprecision

using namespace std;

int main()

{

int size = 0;

cout << "Enter the number of books in the sale: ";

cin >> size;

float array[size], shipping, tax, discont = 0, total, grandTotal;

char sType;

for (int i = 0; i < size; i++)

{

cout << "Enter price : ";

cin >> array[i];

total += array[i];

}

cout << "Enter shipping method [S]Standard shipping [E]Expedited shipping: ";

cin >> sType;

if (sType == 'S')

{

shipping = 4.99;

}

else if (sType == 'E')

{

shipping = 12.99;

}

else

{

cout << "Invalid entry" << endl;

return 0;

}

if (total >= 50 && total <= 100)

{

discont = total * 0.10;

}

else if (total > 100)

{

discont = total * 0.15;

}

tax = total * 0.05;

grandTotal = total + tax - discont + shipping;

cout << fixed << setprecision(2);

cout << "Subtotal: $" << total << endl;

cout << "Tax: $" << tax << endl;

cout << "Discount: $" << discont << endl;

cout << "Shipping: $" << shipping << endl;

cout << "Total: $" << grandTotal << endl;

return 0;

}

Output:

Add a comment
Know the answer?
Add Answer to:
Write a C++ program that will calculate the total amount of money for book sales at...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Language = Java Create a program to receive book prices until a sentinel value is entered....

    Language = Java Create a program to receive book prices until a sentinel value is entered. (Be sure to tell your user what the sentinel value is so they can type it to indicate they are finished with entering input.) After the sentinel value is entered, compute the total book order total and return the following to the user. As book prices are entered, you'll need to have some way to capture the number of books they ordered and the...

  • Modify your Online Book Order program from week 4 to prompt the users for the number...

    Modify your Online Book Order program from week 4 to prompt the users for the number of books they are purchasing. Using a for loop, prompt the user for the cost of each book and store it into a subtotal. Use the subtotal and the number of books to pass to your method. No changes should be needed to your method or parameters. Output a receipt formatted as the following: Enter the number of books purchased: 4 Enter the book...

  • An online retailer wants a program that displays the total amount a customer owes, including shipping....

    An online retailer wants a program that displays the total amount a customer owes, including shipping. The user will enter the total amount due before shipping. The amount to charge for shipping is based on the customer's membership status, which can be either Standard or Premium. The appropriate shipping charges are shown in Figure 9-42. The program should use two program-defined functions: one to determine the shipping charge for a Standard member and the other to determine the shipping charge...

  • Modify your Online Book Order program from week 5 to prompt the users for the number...

    Modify your Online Book Order program from week 5 to prompt the users for the number of books they are purchasing. Using a for loop, prompt the user for the cost of each book and store it into a subtotal. Use the subtotal and the number of books to pass to your method. No changes should be needed to your method or parameters. Output a receipt formatted as the following: Enter the number of books purchased: 4 Enter the book...

  • In C++ Write a program to calculate a car dealer's sale of the same car. Enter...

    In C++ Write a program to calculate a car dealer's sale of the same car. Enter the car price and the number of cars sold. Calculate the tax (9% of each car price). Calculate the shipping charge ($3,000 per car). The price of the car sale is the sum of the total car price for all cars, the tax for all cars, and the shipping charge for all cars. You must display the total price of the car sale at...

  • Write a C++ program that asks for the following information about a book order from the...

    Write a C++ program that asks for the following information about a book order from the console: • Title • Author • ISBN (hint: careful about what data type to use - validate 9 or 13 characters) • Price (validate number < 400) • Quantity (number of books to purchase – validate > 0 and < 100) • Fiction/Non-Fiction (‘N’ or ‘F’ - validate) • Genre (‘R’ romance, ‘D’ drama, ‘M’ mystery – validate) Make use of the following data...

  • 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)...

  • 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

  • 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 =...

  • Help. In language c View Layout References Mailings Program 1 Write a simple invoice generating program...

    Help. In language c View Layout References Mailings Program 1 Write a simple invoice generating program for a pet store as follows: 1- Ask the user for tee tax rate and store it in a float variable. 2- Ask the user for the number of cats being purchased and store the value in an integer variable. 3- Ask the user for the price of one cat and store it in a float variable. 4- Ask the user for the number...

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