CAN ANYONE PLEASE HELP ON THIS PROGRAM FOR MY EXAM..TQ
Write a C program to help a H’s Restaurant automate its
breakfast billing system. Your assignment should implement
the following items:
a. Show the customer the different breakfast items
offered by the H’s Restaurant.
b. Allow the customer to select more than one item
from the menu.
c. Calculate and print the bill to the customer.
d. Produce a report to present your complete program
and show more sample output.
Assume that the H’s Restaurant offers the following
breakfast menu:
Plain Egg $2.50
Bacon and Egg $3.45
Muffin $2.20
French Toast $2.95
Fruit Basket $3.45
Cereal $0.70
Coffee $1.50
Tea $1.80
Your program must do the following task below:
a. Define the data structs, menu item types with two
components: menu item of type string and menu price of type
double. Use an array to declare the data structs.
b. Function get data to loads the data into the array
menu list.
c. Function show menu to show the different breakfast
items offered by the restaurant and tell the user how to
select the items.
d. Function print receipt to calculates and prints the
customer receipt. The billing amount should include a 5%
tax.
e. Format your output with two decimal places. The
name of each item in the output must be left-justify. You
may assume that the user selects only one item of a
particular type.
f. The two sample output as shown:
Welcome to HiFi’s Restaurant
1 Bacon and Egg $3.45
1 Muffin $2.20
1 Coffee $1.50
Tax 5% $0.35
Amount Due $7.50
Answer / ss
Week5
using namespace std;
enum Planet {MERCURY, VENUS, EARTH, MARS,JUPITER,
SATURN, URANUS,NEPTUNE,
PLUTO};
string tolowerstr(string str);
Planet StrToPlanet(string str);
string PlanetToStr(Planet planet);
void readData(double&, Planet&);
double PlanetWeight(double, Planet);
int main()
{//for (Planet p=MERCURY; p<=PLUTO; p=Planet(p+1))
//cout<<PlanetToStr(p)<<endl;
Planet planet;
double weight;
char answer;
do{
cout<<"Enter your weight? "; cin>>w;
cout<<"Enter a planet name? ";cin>>str;
cout<<"Your weight on ";
<<" is "<<PlanetWeight(weight,
planet)<<" kg."<<endl;
cout<<"Press letter s to stop? ";
cin>>answer;
}while (answer!='s' && answer!='S');
return 0;
}//main
Planet StrToPlanet(string str)
{//converts the string str value to its corresponding
Planets value
string cstr=tolowerstr(str); //converts user typed planet
name into lowercase form
if (cstr=="mars")
return MARS;
else if (cstr=="mercury")
return MERCURY;
else if (cstr=="venus")
return VENUS;
else if (cstr=="jupiter")
return JUPITER;
else if (cstr=="neptone")
return NEPTUNE;
else if (cstr=="saturn")
return SATURN;
else if (cstr=="pluto")
return PLUTO;
else
{
if (cstr!="earth")
cout<<"Invalid planet name.\n";
return EARTH;}}//ConvertToPlanets
string tolowerstr(string str)
{
//converts every character in the string str to lowercase
form
for(int i=0; i!=str.length(); i++)
str[i]=tolower(str[i]);
return str;
}
string PlanetToStr(Planet planet)
{
switch (planet)
{
case EARTH: return "Earth";
case JUPITER: return "Jupiter";
case VENUS: return "Venus";
case MARS: return "Mars";
case MERCURY: return "Mercury";
case SATURN: return "Saturn";
case NEPTUNE: return "Neptune";
case PLUTO: return "Pluto";
case URANUS: return "Uranus";
default: return "Error";
}//switch
}//PlanetToStr
double PlanetWeight(double earthweight, Planet p)
{
switch(p)
{
case JUPITER: return 2.5374*earthweight;
case VENUS: return earthweight* 0.8975;
case MARS: return earthweight*0.3507;
case MERCURY: return earthweight*0.4155;
case SATURN: return earthweight*1.0677;
case NEPTUNE: return earthweight*1.1794;
case PLUTO: return earthweight*0.0899;
case URANUS: return earthweight*0.8947;
default: return earthweight;
}//switch
}//PlanetWeight
void readData(double &w, Planet &p){
string str;
cout<<"Enter your weight? "; cin>>w;
cout<<"Enter a planet name? ";cin>>str;
p=StrToPlanet(str);
}
Is This Answer Correct ? | 2 Yes | 12 No |
What are the types of data files?
Write a program to enter the name and age. If age>28 then find salary categories. if age<28 then find that you are gaduate or not.
What will be the outcome of the following conditional statement if the value of variable s is 10?
wat is the output int main() { char s1[]="Hello"; char s2[]="Hello"; if(s1==s2) printf("Same"); else printf("Diff"); }
which of the following statements is incorrect a.typedef struct new{ int n1; char n2; } DATA; b.typedef struct { int n3; char *n4; }ICE; c.typedef union { int n5; float n6; } UDT; d.#typedef union { int n7; float n8; } TUDAT;
What is a pointer and how it is initialized?
what is meant by c
In how much time you will write this c program? Prime nos from 1 to 1000
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
What are the preprocessor categories?
main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
5 Answers Vector, Vector Solutions,
What are pragmas and what are they good for?