Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <array>
- #include <format>
- #include <string>
- int main() {
- auto options = std::to_array<std::string>(
- { "ICU Monitor","Get'er Done! Monitor","Gamer's Delight Monitor", "Checkout" });
- auto prices = std::to_array<float>({ 159.99, 179.99, 249.99 });
- float total = 0.0;
- for(;;)
- {
- std::cout << std::format("\n{0:>13}\n", "MENU");
- for (size_t n = 0; n < options.size(); ++n)
- {
- std::cout << std::format("{0}. {1}", (n + 1), options[n]);
- if (n < prices.size()) std::cout << " $" << prices[n];
- std::cout << "\n";
- }
- std::cout << std::format("\nEnter the option (1-{}): ", options.size());
- int choice;
- std::cin >> choice;
- if ((choice > 0) && (choice <= prices.size()))
- {
- std::cout << "Enter Item Quantity: ";
- int quantity;
- std::cin >> quantity;
- total += quantity * prices[choice - 1];
- }
- else if (choice == options.size()) break;
- else
- {
- std::cout << "Invalid option";
- }
- }
- const float tax_rate = 0.065F;
- float sales_tax = total * tax_rate;
- std::cout <<
- std::format(
- "\nTotal Cost of Monitors: ${0:.2f}"
- "\nSales Tax(calculated at {1:.1f} %) : ${2:.2f}"
- "\nBalance Due: ${3:.2f}\n",
- total, (tax_rate * 100.0), sales_tax, (total + sales_tax));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement