Question

In: Computer Science

Please in C++, show screenshots of output plus .txt file. thanks Breakfast Billing System Write a...

Please in C++, show screenshots of output plus .txt file. thanks

Breakfast Billing System
Write a program to help a local restaurant automate its breakfast billing system. The program should do the following:
Show the customer the different breakfast items offered by the restaurant.
Allow the customer to select more than one item from the menu.
Calculate and print the bill
Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item):

Plain Egg   $1.45
Bacon and Egg   $2.45
Muffin   $0.99
French Toast   $1.99
Fruit Basket   $2.49
Cereal   $0.69
Coffee   $0.50
Tea   $0.75

Use an array, menuList, of the struct menuItemType, with three components: menuItem of string, menuPrice of type double, and Count of type int. Your program must contain at least the following functions:
Function getData: This function loads the data from a file named menu.txt with the above breakfast items into the array menuList.
Function showMenu: This function shows the different items offered by the restaurant and tells the user how to select the items.
Function printCheck: This function calculates and prints the check. (Note that the billing amount should include a 5% tax.)

A sample output is:
Welcome to Johnny’s Restaurant
Bacon and Egg   1   $2.45
Muffin   1   $0.99
Coffee   2   $1.00
Amount Total       $4.44
Tax       $0.22
Amount Due       $4.66

Solutions

Expert Solution

*******************************************Summary**********************************************

The program for above question is given below with comments and output screenshots and file screenshot

The program is working absolutely same as asked in the question

However , there is not much code in main () function , as everything is done in the functions so...

I hope it works for you!!!!!!

********************************************Program**********************************************

#include <iostream>
#include<fstream>        //for reading and writing in file 
using namespace std;

struct menuItem          //struct menuItem
{
     string Item;
     double Price;
     int Count;
};

menuItem menuList[8];         //creating menuList array of type menuItem

void getData()
{
     ifstream file;
     file.open("menu.txt");        //opening file..Note:the pile must be in same folder as .cpp file otherwise you will have to specify the path of file in quotes
     string item,s;      //variables
     double price;
     int i=0;
     
     do{
         getline(file,item,'$');        //reading the string untill $ sign
         file>>price;                   //reading the double value from file and storing in price
         menuList[i].Item=item;         //storing item name in menuList i th element
         menuList[i].Price=price;       //storing item price in menuList i th element
         menuList[i].Count=0;           //setting count =0 of all items
         i++;
     }while(getline(file,s));           //storing a string in s until new line and if the line is stored then continue the loop
     //In above loop if we dont store the line in s ..it takes the \n character of previous line in the Item name ..so had to store it in string s
     file.close();       //closing file
}

void showMenu()
{
     int choice,count;
     cout<<"*****************MENU**********************"<<endl;
     for(int i=0;i<8;i++)
     {
          cout<<(i+1)<<". "<<menuList[i].Item<<"\t"<<menuList[i].Price<<endl;        //printing menu items and prices from menulist
     }
     
     do
     {
         cout<<endl<<"Enter the number of Item you want to order (0 for exit)"<<endl;          //asking for item to order
          cin>>choice; 
     
     if(choice!=0)            //if user doesn't want to exit
     {     cout<<"How much do you want the "<<menuList[choice-1].Item<<endl;         //asking for the quantity of item
          cin>>count;
          menuList[choice-1].Count=count;              //storing the quantity in the count 
     }else if(choice>8)                                //if choice is not in the list
          cout<<"Enter a valid Item"<<endl;
          
     }while(choice!=0);       //continue until user doesn't press 0
}

void printCheck()
{
     double total=0,tax,due;
     ofstream file("bill.txt");              //opening file for printing bill
     cout<<"-----------------------------"<<endl;      //wrting on console
     cout<<"---------Your Bill---------"<<endl;
     
     file<<"-----------------------------"<<endl;      //wrinting in file
     file<<"---------Your Bill---------"<<endl;
     
     for(int i=0;i<8;i++)
     {
          if(menuList[i].Count!=0)                //if the count of ith elemnt of menulist is not zero then it means the user has ordered that item
         { 
              cout<<menuList[i].Item<<"\t"<<menuList[i].Count<<"\t$"<<menuList[i].Price<<endl;       //printing orders on console
           file<<menuList[i].Item<<"\t"<<menuList[i].Count<<"\t$"<<menuList[i].Price<<endl;         //printing orders in file
         }
         total=total+menuList[i].Price*menuList[i].Count;        //storing the total price of ordered items
     }
     
     tax=total*5/100;         //calculating the tax
     due=total+tax;           //calculating the amount due
     
     //printing the total ,tax,amount due on console
     cout<<"------------------------------"<<endl;
     cout<<"Amount Total:\t"<<"$"<<total<<endl;
     cout<<"Tax:\t\t"<<"$"<<tax<<endl;
     cout<<"Amount Due :\t"<<"$"<<due<<endl;
     cout<<"------------------------------"<<endl;
     
     //printing the total ,tax,amount due in file
     file<<"------------------------------"<<endl;
     file<<"Amount Total:\t\t"<<"$"<<total<<endl;
     file<<"Tax:\t\t\t\t"<<"$"<<tax<<endl;
     file<<"Amount Due :\t\t"<<"$"<<due<<endl;
     file<<"------------------------------"<<endl;
     file.close();       //closing file
}

int main()
{
     getData();          //loading the menu into menulist
     showMenu();         //showing menu to user and getting orders
     printCheck();       //calculating total and amount due and printing the bill on console and file
    return 0;
}

menu.txt

Plain Egg      $1.45
Bacon and Egg  $2.45
Muffin         $0.99
French Toast   $1.99
Fruit Basket   $2.49
Cereal         $0.69
Coffee         $0.50
Tea            $0.75

**********************************************Output**************************************************

Console

Output file

Program


Related Solutions

[In Python] Write a program that takes a .txt file as input. This .txt file contains...
[In Python] Write a program that takes a .txt file as input. This .txt file contains 10,000 points (i.e 10,000 lines) with three co-ordinates (x,y,z) each. From this input, use relevant libraries and compute the convex hull. Now, using all the points of the newly constructed convex hull, find the 50 points that are furthest away from each other, hence giving us an evenly distributed set of points.
C++ The txt file is not showing up in my output #include <iostream> #include <fstream> #include...
C++ The txt file is not showing up in my output #include <iostream> #include <fstream> #include <string> #include "Classroom.h" using namespace std; Classroom myLib; void loadDataset(string fileName) { ifstream myFile; myFile.open(fileName.c_str()); } void continueMessage(string message) { cout << message << endl; cout << "Press Enter to continue.." << endl; cin.get(); } int main() { string fileName = "dataset.txt"; loadDataset(fileName); myLib.print(); continueMessage; string ID = "Janet Newman"; myLib.removeStudent (ID); continueMessage("Janet Newman has been removed."); //--------------------------------------------------------------------------- myLib.print(); continueMessage("All students are listed!"); return...
Please write the program in JAVA and provide me with the output screenshots!! Assignment Objectives •...
Please write the program in JAVA and provide me with the output screenshots!! Assignment Objectives • Be able to write methods • Be able to call methods Introduction Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing the smaller tasks (calling the methods) in the correct...
Please attach the output screenshots, narrative descriptions, or paste the Python codes. Please write code to...
Please attach the output screenshots, narrative descriptions, or paste the Python codes. Please write code to print the type of the following variables. Please write down the codes and the output as well. x = 3.5 y = '3.5' z = {1:'John', 2:'Wick', 3:'Barry', 4:'Allen'}
Please submit SQL statements as a plain text file (.txt). If blackboard rejects txt file you...
Please submit SQL statements as a plain text file (.txt). If blackboard rejects txt file you can submit a zipped file containing the text file. Word, PDF, or Image format are not accepted. You do not need to show screen shot. Make sure you have tested your SQL statements in Oracle 11g. Problem 1. Please create the following tables for a tool rental database with appropriate primary keys & foreign keys. [30 points] Assumptions: Each tool belongs to a category....
Please submit SQL statements as a plain text file (.txt). If blackboard rejects txt file you...
Please submit SQL statements as a plain text file (.txt). If blackboard rejects txt file you can submit a zipped file containing the text file. Word, PDF, or Image format are not accepted. You do not need to show screen shot. Make sure you have tested your SQL statements in Oracle 11g. The list of tables is: Tables: Cust Table: cid, -- customer id cname, --- customer name cphone, --- customer phone cemail, --- customer email Category table: ctid, ---...
Write a python program: There is a file called file 2. File2 is a txt file...
Write a python program: There is a file called file 2. File2 is a txt file and I have written the contents of file 2 below in the exact format it was in notepad. # This comment does not make sense # It is just to make it harder # The job description starts after this comment, notice that it has 4 lines. # This job description has 700150 hay system points\\ the incumbent will administer the spending of kindergarden...
PLEASE do the following problem in C++ with the screenshot of the output. THANKS! Assuming that...
PLEASE do the following problem in C++ with the screenshot of the output. THANKS! Assuming that a text file named FIRST.TXT contains some text written into it, write a class and a method named vowelwords(), that reads the file FIRST.TXT and creates a new file named SECOND.TXT, to contain only those words from the file FIRST.TXT which start with a lowercase vowel (i.e., with 'a', 'e', 'i', 'o', 'u'). For example, if the file FIRST.TXT contains Carry umbrella and overcoat...
I would need both SAS & R code, the output and .txt file/s, please. Because many...
I would need both SAS & R code, the output and .txt file/s, please. Because many HMOs either do not cover mental health costs or provide only minimal coverage, min- isters and priests often need to provide counseling to persons suffering from mental illness. An in- terdenominational organization wanted to determine whether the clerics from different religions have different levels of awareness with respect to the causes of mental illness. Fifteen clerics from different Christian denominations were sampled. Each was...
write in C++ as simple as possible please and thanks don't use header file <bits/stdc++.h> All...
write in C++ as simple as possible please and thanks don't use header file <bits/stdc++.h> All programs work with binary numbers which are powers of 2 (2, 4, 8, …).  Write a program that will have a user enter a number (n) less than 10,000. Then have the program put each power of 2 (int) into an array up to and possibly including the number n. This means you don't know at the start how large the array will be, so...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT