Write a stub for function double totalPricedouble singlepric
Write a stub for function double totalPrice(double single_price, int total_items)
Solution
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
const int SIZE = 5;
double COFFEEPRICE = 2.00;
string products [SIZE] = { \"chocolate\",\" chocolate coffee \",\"chocolate sauce\",\" choco cake\",\" fanta drink\"}
double prices[SIZE] = {0.89 ,0.25,0.59,1.50,1.75}
double totalPrice = 0;
int choice = 0;
int SENTINEL = -1 ;
do
{
cout<<\" Please select an item from the Product menu by selecting the item number (1-5) or -1 to terminate:\";
cout<< \" Product Price ( $ ) \" << end1;
cout<< \"======== ========\"<< end1;
cout<< \" 1. chocolate 0.89 \" << end1;
cout << \" 2. chocolate coffee 0.25\" << end1;
cout << \" 3.chocolate sauce 0.89\" << end1;
cout<< \" 4.choco cake 1.50\" << end1;
cout << \" 5.fanta drink 1.75\" << end1;
cout << \" Please enter positive number : \" << end1;
cin >> choice ;
if ( choice > SENTINEL )
{
if ( ( choice > = 1 ) && ( choice <= 5 ) )
{
totalPrice = totalPrice + prices [ choice - 1 ];
cout << \" Item number \" << choice << \" : \"<< products[choice - 1] << \" has been added \" << end1;
}
else
{
cout << \" Item number \" , choice , \" is not valid \", \"Sorry we do not carry that item \";
}
}
totalPrice = totalPrice + COFFEEPRICE;
cout << \" Total price of order is $ \" << totalPrice << end1;
cout << \" Thanks for purchasing from Foodex Shop \" << end 1;
}while ( choice <= SENTINEL );
return 0;
}


