Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- int main() {
- string command;
- cin >> command;
- double totalPrice = 0, price;
- while (command != "special" && command != "regular") {
- price = stod(command);
- if (price > 0) {
- totalPrice += price;
- }
- else {
- cout << "Invalid price!\n";
- }
- cin >> command;
- }
- if (totalPrice == 0) {
- cout << "Invalid order!\'n";
- }
- else {
- cout << fixed << setprecision(2) <<
- "Congratulations you've just bought a new computer!\n" <<
- "Price without taxes: " << totalPrice << "$\n" <<
- "Taxes: " << totalPrice / 5 << "$\n" <<
- "-----------\n" <<
- "Total price: " << totalPrice * 1.2 * (command == "special" ? 0.9 : 1) << "$\n";
- }
- return 0;
- }
Advertisement
Advertisement