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 |
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
Why pointers are used in c?
Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words. Demonstrate the usage of this function from a main program. Example: Parameter: “jack and jill went up a hill” Return Value: “kcaj dna llij tnew pu a llih”
Can include files be nested?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL
What does typeof return in c?
Describe the steps to insert data into a singly linked list.
What is null pointer constant?
How many types of sorting are there in c?
In C language, a variable name cannot contain?
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?