Professional Documents
Culture Documents
New Rich Text Document
New Rich Text Document
#include <string>
#include <iomanip>
struct Product {
std::string name;
double price;
};
std::cout << i + 1 << ". " << products[i].name << " - $" << products[i].price << "\n";
while (true) {
if (choice == 0) break;
continue;
std::cout << "Enter quantity for " << products[choice - 1].name << ": ";
if (quantity < 0) {
continue;
quantities[choice - 1] += quantity;
if (quantities[i] > 0) {
<< " = $" << std::fixed << std::setprecision(2) << cost << "\n";
total += cost;
}
std::cout << "--------------------------------\n";
std::cout << "Total: $" << std::fixed << std::setprecision(2) << total << "\n";
int main() {
Product products[MAX_PRODUCTS] = {
{"Apple", 0.50},
{"Banana", 0.30},
{"Orange", 0.80},
{"Milk", 1.20},
{"Bread", 1.50}
};
printMenu(products, MAX_PRODUCTS);
return 0;