Question

C++ HELP I need help with this program. I have done and compiled this program in...

C++ HELP

I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files

1. bill.h = contains the class program with methods and variables

eg of class file

class bill

{

}

2. bill.cpp = contains the functions from class file

3. main.cpp = contains the main program.

Please split this program into three files and make the program run. I have posted the code here.

#include<iostream>

using namespace std;

int again;
int total=0;
int bfrate[7][2]={ {0,30},
{1,35},
{2,40},
{3,20},
{4,15},
{5,20},
{6,30}
};

int purchased[][3]={{0,0},
{0,0},
{0,0},
{0,0},
{0,0},
{0,0},
{0,0}
};

void bfast(char bfmenu[][100]);
void main_menu();
void display();
void display_bf_bill(char bfmenu[][100]);
void display_bfmenu();
void repeatbf(char bfmenu[][100]);


int main()
{
char bfmenu[][100]={"toast","Idli-wada","Dosa","Upma","milk","tea","coffee"};
char choice;
do
{
enter:
display();
printf("Enter your choice here : "); // //The printf() function displays the standard output.//
scanf("%c", &choice); //The scanf() function reads the data from standard input(user input) and stores the values into the respective variables.//
switch(choice)
{
case 'A':
case 'a':cout<<"\nBreakfast\n"<< endl;
bfast(bfmenu);
break;

default:printf("\nWrong choice entered Please enter the valid choice!!\n");
goto enter;
}
}while(choice!='d');
}
void display()
{
printf(" Welcome to Breakfast Restaurant. \n ");
printf(" +============================+ \n\n");
printf(" && Please select the meal that you would like to purchase. && \n\n");
printf("\t\t [A] Breakfast\n");
}
void display_bfmenu()
{
printf(" Welcome to Breakfast Restaurant. \n ");
printf(" +============================+ \n\n");
printf(" $ Breakfast Menu $ \n\n");
printf(" && Please select the food that you would like to purchase. && \n\n");
printf("\t\t [0] Toast - Rs 30.00\n");
printf("\t\t [1] Idli-Vada - Rs 35.00\n");
printf("\t\t [2] Dosa - Rs 40.00\n");
printf("\t\t [3] UPMA Rs 20.00\n");
printf("\t\t [4] Milk- Rs 15.00\n");
printf("\t\t [5] Tea - Rs 20.00\n");
printf("\t\t [6] Coffee - Rs 30.00\n");
}
void bfast(char bfmenu[][100]) //Breakfast Menu Screen
{
int choice = 0; //local variables
int quantity = 0;
int again = 0;
int code,i;
display_bfmenu();
printf("\nEnter the code: \n");
scanf("%d", &code);
if(code>=0&&code<=6)
{
printf("\nEnter the quantity: \n");
scanf("%d",&quantity);
purchased[code][1]= quantity*bfrate[code][1]; /*purchased[code][1]+ (quantity*bfrate[code][1]);*/
total+=purchased[code][ 1];
}
else
{
printf("\nInvalid code entered, Please enter the code again!!!! \n");
bfast(bfmenu);
}
repeatbf(bfmenu);
}
void repeatbf(char bfmenu[][100])
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : "); // Allows user to choose whether to check-out or buy anything else.
scanf("%d",&again);
if (again == 1)
bfast(bfmenu);
else if (again == 2 )
{
display_bf_bill(bfmenu);
exit(0);
}
else
{
printf("\n\n\t\tSorry Invalid Decision Entered\n");
repeatbf(bfmenu);
}
}
void display_bf_bill(char bfmenu[][100])
{
int i;
printf(" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ \n\n");
printf(" Breakfast RESTAURANT \n");
printf(" BILLING INFORMATION \n");
printf("\t\t ITEMS\t\tPrice(in Rs.)\n");
for(i=0;i<7;i++)
{
if(purchased[i][1]!=0)
{
printf("\t\t%s\t\t",bfmenu[i]);
printf("%d\n",purchased[i][1]); /*purchased[i][1]);*/
}
}
printf("\t\tTotal=Rs.%d\n",total);
printf("\n\n +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ \n\n");

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the separate files from the links below:

bill.h - https://www.dropbox.com/s/2lko5xf3k1i6n7c/bill.h?dl=0

bill.cpp - https://www.dropbox.com/s/wsrpj1y65rju708/bill.cpp?dl=0

main.cpp - https://www.dropbox.com/s/cgt5g5usw36e7wl/main.cpp?dl=0

bill.h

bill.cpp

main.cpp

Add a comment
Know the answer?
Add Answer to:
C++ HELP I need help with this program. I have done and compiled this program in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...

  • Need help with this C program? I cannot get it to compile. I have to use...

    Need help with this C program? I cannot get it to compile. I have to use Microsoft Studio compiler for my course. It's a word game style program and I can't figure out where the issue is. \* Program *\ // Michael Paul Laessig, 07 / 17 / 2019. /*COP2220 Second Large Program (LargeProg2.c).*/ #define _CRT_SECURE_NO_DEPRECATE //Include the following libraries in the preprocessor directives: stdio.h, string.h, ctype.h #include <stdio.h> /*printf, scanf definitions*/ #include <string.h> /*stings definitions*/ #include <ctype.h> /*toupper, tolower...

  • C program help: Write a C program that uses three functions to perform the following tasks:...

    C program help: Write a C program that uses three functions to perform the following tasks: – The first function should read the price of an item sold at a grocery store together with the quantity from the user and return all the values to main(). example: #include void getInput(int *pNum1, int *pNum2); // note: *pNum1 & *pNum2 are pointers to ints int main () {    int numDucks,numCats;    getInput(&numDucks, &numCats); // passing addresses of num1 & num2 to...

  • Using C, I need help debugging this program. I have a few error messages that I'm...

    Using C, I need help debugging this program. I have a few error messages that I'm not sure how to fix. Here is the code I have: /* * C Program to Print a Linked List in Reverse Order */ #include <stdio.h> #include <stdlib.h> struct node { int num; struct node *next; }; int main() { struct node *p = NULL; struct node_occur *head = NULL; int n; printf("Enter data into the list\n"); create(&p); printf("Displaying the nodes in the list:\n");...

  • This is for a C++ program: I'm almost done with this program, I just need to...

    This is for a C++ program: I'm almost done with this program, I just need to implement a bool function that will ask the user if they want to repeat the read_course function. I can't seem to get it right, the instructions suggest a do.. while loop in the main function. here is my code #include <iostream> #include <cstring> #include <cctype> using namespace std; const int SIZE = 100; void read_name(char first[], char last[]); void read_course(int & crn, char des[],...

  • C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt...

    C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...

  • C Programming I have this cost estimation program, but I want to add to it more...

    C Programming I have this cost estimation program, but I want to add to it more functions to be more accurate and more useful. I want to add to the program an array and a loop that can help me with the materials that can be use to the building, as ceramic, wood and concrete and extra functions. ########## #include <stdio.h> int main(void) { float wid,len,yrs; int metersq = 2000; int floors,rooms,win,doors,restrooms,umet; char floortype[20]; char ti[20]; int woodfloor = 25;...

  • C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want...

    C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...

  • I made this C program to count change and make a slip saying the exact dollar...

    I made this C program to count change and make a slip saying the exact dollar and change amount given. every time I run the program it says the change given is 477256577 and i'm not sure what I have done wrong? #include<stdio.h> int main(void) { char first, last; int pennies; int nickels; int dimes; int quarters; int loonies; int change; int t_dollars; int t_cents; printf("Type in your 2 initials and press return> "); scanf("%c%c",&first,&last); printf("%c%c please enter in your...

  • Need help with a C++ problem I have

    For my assignment I have to write a program that creates a restaurant billing system. I think that I got it correct but it says that it is incorrect, so I was wondering if someone would be able to look over my code. It says that I need tax of $0.20, and the amount due to be $4.10, which is what I have in my output.https://imgur.com/a/jgglmvWMy issue is that I have the correct outcome when I run my program but...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT