I need help with this please

A t-shirt shop sells shirts that retail for $16. Quantity discounts are given as follow:
Number of Shirts Discount
10-20 10%
21-40 15%
41-60 20%
61 or more 25%

Write a C++ program that prompts the user for the number of shirts required and then computes corresponding discount, and the total price. Assume a sale tax of 11.5%. The program will display the customer saving (discount in dollars), sales tax in dollars and the total price
Hello cu123,

What have you tried so far to solve this? Show us your attempt, so that we can see what you're struggling with.

http://www.cplusplus.com/doc/tutorial/

(Also, sales tax of 11.5%??? I'm glad I don't live wherever you are.)
Last edited on
There is a problem very similar in the Forum but I don't know how to add the sale tax. ** I don't know how to do the last two sentences
Assuming that any sales tax is calculated after the discount, you'd just do something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

int main()
{
    double total_price_pre_tax = 42.00;
    double sales_tax = 0.115; // 11.5%

    double total_price = total_price_pre_tax + total_price_pre_tax * sales_tax;
    
    std::cout << "Price:       " << total_price_pre_tax << '\n';
    std::cout << "Sales tax:   " << sales_tax * 100.0 << "%\n";
    std::cout << "Total price: " << total_price << '\n';
}
Last edited on
42?? where did it come from
closed account (E0p9LyTq)
42?? where did it come from

If Douglas Adams were still alive you could ask him.

https://en.wikipedia.org/wiki/The_Hitchhiker's_Guide_to_the_Galaxy
Topic archived. No new replies allowed.