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



CAN ANYONE PLEASE HELP ON THIS PROGRAM FOR MY EXAM..TQ Write a C program to help a H’s Restaura..

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

Post New Answer

More C Interview Questions

How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include<stdio.h>...

0 Answers  


Please write me a program to print the first 50 prime numbers (NOT between the range 1 -50)

5 Answers   IBM, KJH,


Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.

0 Answers  


Can you mix old-style and new-style function syntax?

0 Answers  


Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?

0 Answers  






Is this program statement valid? INT = 10.50;

0 Answers  


Describe the header file and its usage in c programming?

0 Answers  


Write an interactive c program that will encode or decode a line of text. To encode a line of text, proceed as follows: Convert each character, including blank spaces, to its ASCII equivalent. Generate a positive random integer. Add this integer to the ASCII equivalent of each character. The same random integer will be used for the entire line of text. Suppose that N1 represents the lowest permissible value in the ASCII code, and N2 represents the highest permissible value. If the number obtained in step 2 above exceeds N2, then subtract the largest possible multiple of N2 from this number, and add the remainder to N1. Hence the encoded number will always fall between N1 and N2, and will therefore always represent some ASCII character. Display the characters that correspond to the encoded ASCII values. The procedure is reversed when decoding a line of text. Be certain, however, that the same random number is used in decoding as was used in encoding.

1 Answers   Amazon, CSJM, HCL, Microsoft, TCS, Wipro,


Identify the correct argument for the function call fflush () in ANSI C: A)stdout B)stdin C)stderr D)All the above

5 Answers   Accenture, TCS,


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

0 Answers   Amdocs, Apps Associates,


. Write a program to get a string and to convert the 1st letter of it to uppercase

2 Answers   HTC,


For what purpose null pointer used?

0 Answers  


Categories