Execution of a program for Personal Budget in C++


Modify your program for Homework 2 to support 5 categories of expenses. Use parallel arrays for expense names and values. Instead of menu choices 1-4, use one menu choice to enter an expense. Display available choices and make the user enter the number for the corresponding category.


1. Submit as interest.cpp and restaurant.cpp files

2. Run and test your program.

3. Include proper comments to document aspects of your program. One should be a multi-line comment at the top of the program, including class code, term, section, your name, and the program’s purpose. Strive for maximum readability.

4. Use proper programming style.


In this question, we have implemented a restaurant scenario in C++. When the user chooses to sell coffee, we will display a coffee menu, and every time user can enter the choice of coffee and the quantity. When the user has chosen his orders and wants to exit from the program, he has to click on the exit program option in order to complete the sale. Once the user exits the program, we will display all the details about the sale. If the user chooses to get the number of cups he has chosen, then we will display the number of cups of each type sold. And, if the user chooses the number of ounces, then we will display the number of ounces of each type. If the user requires help, he can click the help option. And, if the user chooses to exit, then we will close the console. 


We have to write a program for the execution of the restaurant menu. We have implemented the class “coffee”. In the “coffee” class, we have defined a couple of data members with the names s, m, l to hold the cups of respective their size. We have used s_cost, m_cost, l_cost to hold the amount obtained on selling each type of coffee. And, we have used  l_ounces, s_ounces, m_ounces to get the respective ounces of coffee sold. Here, s, m, and, l represents the size of cups as small, medium, and large. We have declared the variable “total” to hold the total amount obtained on sales, “tax” to hold the total tax obtained. And we have declared the variable total_due which will keep the sum of total and tax.

We have implemented the function “Sell_coffee” in which first we display the coffee menu, and then we will ask the user to choose a kind of coffee and its quantity. We will keep an option to complete that sale also, when the user that button, we will display all the details about that sale.

We have implemented the function “total_cups_sold()” which displays how many cups are sold for each type of coffee.
And, we have implemented the function “total_ounces_sold()” and this function will display the total number of ounces of each type of coffee sold.
We also have implemented the function “total_amount()” to display the total amount received on selling coffee.
In the main method, we have implemented a menu-driven scenario where we will ask the user to choose any option he wants or he can also choose exit to leave.


#include <iostream>
using namespace std;
#include <iomanip>
/* to implement coffee class scenario */
class coffee{
    /* to have the number of small,mediunm and large sold */
    int s,m,l;
    double s_cost,m_cost,l_cost;
    int s_ounces,m_ounces,l_ounces;
    double total, tax, total_due;
    /* default constructor */
        s=0; m=0; l=0;
        s_cost=0.0; m_cost=0.0; l_cost=0.0;
        s_ounces=0; m_ounces=0; l_ounces=0;
    void Sell_coffee(){
        int choice;
            /* to display the coffee menu */
            cout<<"Coffee Sale Menu\n1. Small Cup - 9oz.";
            cout<<"\n2. Medium Cup - 12oz.\n3. Large Cup - 16oz.\n4. Complete Sale\n\n";
            /* to choose from the coffee menu */
            cout<<"Make a Selection: "; cin>>choice;
                /* to get the details about small coffee */
                cout<<"How many small cups of coffee: "; int x;
                s+=x; s_cost+=x*1.75; s_ounces+=x*9;
            /* to get the number of medium cups wanted */
            else if(choice==2){
                cout<<"How many medium cups of coffee: "; 
                int x; cin>>x;
                m+=x; m_cost+=x*1.90; s_ounces+=x*12;
            /* to get the number of large cups wanted */
            else if(choice==3){
                cout<<"How many large cups of coffee: ";
                int x; cin>>x;
                l+=x; l_cost+=x*2.00; l_ounces+=x*15;
            /* to complete the sale and display the sale details */
            else if(choice==4){
                cout<<"Total Sale"<<endl;
                cout<<setw(4)<<s<<setw(12)<<"small cups  = $"; cout<<right;
                cout<<left<<setw(4)<<m<<setw(12)<<"medium cups = $"; cout<<right;
                cout<<left<<setw(4)<<l<<setw(12)<<"large cups  = $"; cout<<right;
                cout<<left<<setw(15)<<"Total Sales:  $"; 
                cout<<left<<setw(15)<<"Tax:          $";
                cout<<setw(15)<<"Total Due:    $";
                cout<<"Press any key to continue . . ."<<endl<<endl;
    /* to display the total amount of sales */
    void total_amount(){
        cout<<"Total amount earned today:  $ ";
        cout<<"Press any key to continue . . ."<<endl<<endl;
    /* to help */
    void help(){
        cout<<"We are gald to help you!!\nChoose 1 to sell coffee and display";
        cout<<"all the details about the sale.\nChoose 2 to know the total number of ";
        cout<<"cups sold.\nChoose 3 to know the total ounces of coffee sold\n";
        cout<<"Choose 4 to know the amount of sales\nChoose 6 to exit"<<endl<<endl;
    /* to display the number of cups sold */
    void total_cups_sold(){
        cout<<"Total number of small cups sold today:  "<<s<<endl;
        cout<<"Total number of medium cups sold today:  "<<m<<endl;
        cout<<"Total number of large cups sold today:  "<<l<<endl;
        cout<<"Press any key to continue . . ."<<endl<<endl;
    /* to display the ounces of coffe sold */
    void total_ounces_sold(){
        cout<<"Total ounces sold today:   ";
        cout<<"Press any key to continue . . ."<<endl<<endl;
/* driver code */
int main()
    int choice; 
    coffee c;
        cout<<"Welocome to Jason's Coffee Shop.\nPlease choose from the menu below:\n\n";
        cout<<"1. Make a Sale\n2. Total Cups Sold\n3. Total Ounces Sold\n";
        cout<<"4. Total Amount of Sales\n5. Help\n6. Exit Program"<<endl<<endl;
        cout<<"Menu Choice: "; cin>>choice;
        else if(choice==2)
        else if(choice==3)
        else if(choice==4)
        else if(choice==5)
        else if(choice==6)


Output for the execution of the restaurant menu is given below.

Execution of the restaurant menu output


Also read, using c++ implement the following methods


Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *