Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <iomanip>
- using namespace std;
- // Enter any number of prices.
- // Discount each one 25%, then sum them and
- // add a 10% tax to the total.
- // Display the discounted prices and the final total.
- int main()
- {
- vector<float> discounted_prices; // A string that may represent a number.
- float price = 0; // Individual prices.
- float discount_price = 0; // Price after 25% discount.
- float sum_of_discounted_prices = 0; // Sum of discounted prices.
- float final_price = 0; // Final price after 25% discount and 10% tax.
- cout << "Enter any number of prices.\n"
- "Enter -1 when done\n";
- cin >> price; // Get the next price.
- while (price != -1) // While there are more prices to enter,
- {
- discount_price = .75 * price; // Discount the price.
- sum_of_discounted_prices += discount_price; // Add it to the sum.
- discounted_prices.push_back(discount_price); // Store the price.
- cin >> price; // Get the next price.
- }
- final_price = .9 * sum_of_discounted_prices; // Take 90% of sum.
- cout << "\nList of prices after 25% discount.\n";
- for (float saved_price : discounted_prices) // For each price,
- {
- // Display two decimal points.
- cout << fixed << setprecision(2) << saved_price << '\n';
- }
- // Display the final price.
- cout << "\nFinal total including 10% tax = " << final_price << '\n';
- return 0; // End the program.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement