#include <iostream>
using namespace std;
int main()
{
int food, product, total;
double price;
cout << " Welcome To Maggie’s Shopping Cart Calculator!" << endl;
char option; // user's entered option will be saved in this variable
do{
//Displaying Options for the menu
cout << " 1) Please add an item to your cart " << endl;
cout << " 2) Final Total Amount" << endl;
cout << " 3) Quit the program" << endl; //Prompting user to enter an option according to menu
cout << " Please select an option : ";
cin >> option; // users option
total = price;
if (option == 1) // Checking if user selected option 1
{
cout << " Please enter item and the price : " << endl;
cin >> food;
cin >> price;
cout << " Total amount so far: " << price << endl;
}
else if (option == 2)
cout << "Total Amount so Far: " << total << endl;
else if (option == 3) // Checking if user selected option 2
{
cout << " End Shopping Cart! " << endl;
}
}
while (option != 3);
system("pause");
return 0;
}
This is my code that I have, I just continues to repeat the menu, even when I select an option help! The assignment is to have three options for the user to choose, and the menu should be repeated after choice 1 was selected. My code isn't letting me enter in any information.
Aucun commentaire:
Enregistrer un commentaire