C++ Codes in Programming
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{ int number, n;
int total = 0.0;
char ask;
double cash;
int price[5] = {50, 65, 100, 125, 150};
retry: cout <<"---Well's FAST FOOD RESTAURANT--- \n\n";
cout <<"=============================="<< endl;
cout <<" LIST "<< endl;
cout <<"=============================="<< endl;
cout <<"\n";
cout <<"FOODS \t PRICE "<< endl;
cout <<"\n";
cout <<"1. BURGER............Php 50.00"<< endl;
cout <<"2. FRIES.............Php 65.00"<< endl;
cout <<"3. NACHOS............Php 100.00"<< endl;
cout <<"4. PIZZA.............Php 125.00"<< endl;
cout <<"5. ICE CREAM.........Php 150.00"<< endl;
cout <<"\n";
cout <<"Select food you want to buy: ";cin>>number;
cout <<"\n";
switch(number){ case 1: cout <<"How many you want to buy: ";cin>>n;
cout <<"\n"; total += price[0]*n;
cout <<"Do you want to buy something else? (Y/N)"; cin>>ask;
if(ask == 'Y'){
goto retry;
}
else {
goto end;
}
case 2: cout <<"How many you want to buy: ";cin>>n;
cout <<"\n";
total += price[1]*n;
cout <<"Do you want to buy something else? (Y/N)"; cin>>ask;
if(ask == 'Y'){
goto retry;
}
else {
goto end;
}
case 3:
cout <<"How many you want to buy: ";cin>>n;
cout <<"\n";
total += price[2]*n;
cout <<"Do you want to buy something else? (Y/N)"; cin>>ask;
if(ask == 'Y'){
goto retry;
}
else {
goto end;
}
case 4:
cout <<"How many you want to buy: ";cin>>n;
cout <<"\n";
total += price[3]*n;
cout <<"Do you want to buy something else? (Y/N)"; cin>>ask;
if(ask == 'Y'){
goto retry;
}
else {
goto end;
}
case 5:
cout <<"How many you want to buy: ";cin>>n;
cout <<"\n";
total += price[4]*n;
cout <<"Do you want to buy something else? (Y/N) \n"; cin>>ask;
if(ask == 'Y'){
cout << "\n"; goto retry;
}
else {
goto end;
}
end:
cout <<"Total amount you must pay is: Php " <<total;
cout <<"\n";
cout << "Cash: ";
cin >> cash;
cout <<"Change: " << cash - total;
}
}