Can someone help me fill in the first part of this c++ code:
I need it to print the menu based on the day selected.
#include
#include
using namespace std;
int main(){
double sub_total=0,tax=0,total=0;
string food1[3]={"T-Bone Steak","Pork Chops","Iceland Cod"};
double prices_f1[]={20.50,15.45,10.55};
string food2[3]={"Sirloin Steak","Salmon Fillet","Jumbo Shrimp"};
double prices_f2[]={30.35,24.50,15.50};
string food3[3]={"Pork Tenderloin","Buffalo Chicken Sandwhich","Avocado Burger"};
double prices_f3[]={10.60,15.60,25.60};
string drink1[3]={"Raspberry Sgroppino","Sparkling Apple Sangria ","Spiced Cranberry Rum"};
double prices_d1[]={2.55,5.75,4.25};
string drink2[3]={"Champagne Mojitos","Roman Hoilday Cocktail","Dry Martini"};
double prices_d2[]={1.5,3,25,8.45};
string drink3[3]={"Radler Beer","Port wine","Primm's"};
double prices_d3[]={3.55,2.25,4.45};
int day=0;
cout<
cout<<"1. Monday-Friday\n2.Saturday\n3.Sunday\nEnter :";
cin>>day;
cout<<"Enter Number To Order\n-1 To Stop\n";
if(day==1){ //monday-friday
menu(food1,drink1,prices_f1,prices_d1);
int num,n;
while(1){
cout<<"\nEnter number: ";
cin>>num;
if(num==-1)
break;
//add price to sub_total
if(num>=3&&num<6){
sub_total+=n*prices_d1[num-3];
}else if(num>=0&&num<3){
sub_total+=n*prices_f1[num];
}
}
}else if(day==2){ //Saturday
menu(food2,drink2,prices_f2,prices_d2);
int num,n;
while(1){
cout<<"\nEnter number: ";
cin>>num;
if(num==-1)
break;
if(num>=3&&num<6){
sub_total+=n*prices_d2[num-3];
}else if(num>=0&&num<3){
sub_total+=n*prices_f2[num];
}
}
}else if(day==3){ //Sunday
menu(food3,drink3,prices_f3,prices_d3);
int num,n;
while(1){
cout<<"\nEnter number: ";
cin>>num;
if(num==-1)
break;
if(num>=3&&num<6){
sub_total+=n*prices_d3[num-3];
}else if(num>=0&&num<3){
sub_total+=n*prices_f3[num];
}
}
}else cout<<"ERROR\n";
//Total everything up
tax=sub_total*0.0629;
total=sub_total+tax;
cout<<"\n\nYour Bill\n";
cout<<"Sub total: "<
cout<<"Taxes : "<
cout<<"Total : "<
}
Source Code in C++:
#include <iostream>
#include <iomanip>
using namespace std;
//function to input and validate the food order. Since there are
3 food items available, input must be between 1 to 3
int food()
{
int food;
do
{
cout << "Enter the food code you want to order(1-3) :
";
cin >> food;
if(food>=1 && food<=3)
return food;
else
cout << "Invalid order. Try again with a valid order between
1 and 3." << endl;
}while(true);
}
//function to input and validate the drink order. Since there are 3
drinks available, input must be between 1 to 3
int drink()
{
int drink;
do
{
cout << "Enter the drink code you want to order(1-3) :
";
cin >> drink;
if(drink>=1 && drink<=3)
return drink;
else
cout << "Invalid order. Try again with a valid order between
1 and 3." << endl;
}while(true);
}
//function to input and validate the day. Since there are 7 days in
a week, input must be between 1 to 7
int day()
{
int day;
do
{
cout << "Enter the day of the week (1 for Monday, 2 for
Tuesday and so on) : ";
cin >> day;
if(day>=1 && day<=7)
return day;
else
cout << "Invalid day. Try again with a valid day between 1
and 7." << endl;
}while(true);
}
void printMenu(string food[],double priceFood[],string
drinks[],double priceDrinks[])
{
cout << "Food Code" << setw(10) << "Name"
<< setw(10) << "Price" << endl;
for(int i=0;i<3;i++)
{
cout << i+1 << setw(20) << food[i] <<
setw(10) << priceFood[i] << endl;
}
cout << "Drink Code" << setw(10) << "Name"
<< setw(10) << "Price" << endl;
for(int i=0;i<3;i++)
{
cout << i+1 << setw(25) << drinks[i] <<
setw(5) << priceDrinks[i] << endl;
}
}
//main function
int main()
{
string food1[]={"T-Bone Steak","Pork Chops","Iceland Cod"}; //menu
for Monday to Friday
double priceFood1[]={20.50,15.45,10.55};
string drink1[]={"Raspberry Sgroppino","Sparkling Apple Sangria
","Spiced Cranberry Rum"};
double priceDrink1[]={2.55,5.75,4.25};
string food2[]={"Sirloin Steak","Salmon Fillet","Jumbo Shrimp"};
//menu for Saturday
double priceFood2[]={30.35,24.50,15.50};
string drink2[]={"Champagne Mojitos","Roman Holiday Cocktail","Dry
Martini"};
double priceDrink2[]={1.5,3,25,8.45};
string food3[]={"Sirloin Steak","Salmon Fillet","Jumbo Shrimp"};
//menu for Sunday
double priceFood3[]={10.60,15.60,25.60};
string drink3[]={"Radler Beer","Port wine","Primm's"};
double priceDrink3[]={3.55,2.25,4.45};
int d=day();
if(d>=1 && d<=5) //checking if day is monday to
friday
{
printMenu(food1,priceFood1,drink1,priceDrink1); //printing
menu
int f=food(); //taking order
int dr=drink();
cout << "You ordered " << food1[f-1] << " and "
<< drink1[dr-1] << endl;
cout << "Total price is : " <<
priceFood1[f-1]+priceDrink1[dr-1] << endl;
}
if(d==6) //checking if day is saturday
{
printMenu(food2,priceFood2,drink2,priceDrink2); //printing
menu
int f=food(); //taking order
int dr=drink();
cout << "You ordered " << food2[f-1] << " and "
<< drink2[dr-1] << endl;
cout << "Total price is : " <<
priceFood2[f-1]+priceDrink2[dr-1] << endl;
}
if(d==7) //checking if day is sunday
{
printMenu(food3,priceFood3,drink3,priceDrink3); //printing
menu
int f=food(); //taking order
int dr=drink();
cout << "You ordered " << food3[f-1] << " and "
<< drink3[dr-1] << endl;
cout << "Total price is : " <<
priceFood3[f-1]+priceDrink3[dr-1] << endl;
}
return 0;
}
Output:

Can someone help me fill in the first part of this c++ code: I need it...
FILL IN THE BLANKS #include #include <> *BLANK* using namespace std; int main() { const double HOURLY_RATE = 15; string input_str; cout << "Enter days of attendance: " << endl; *BLANK* (cin, input_str); stringstream input_stream(); int total_hours = 0; while(!input_stream.())*BLANK* { int hours; string day; input_stream >> day; if(day == *BLANK*|| day == *BLANK*) { hours = 5; } *BLANK*(day == "Tuesday" || day == "Thursday") { hours = 4; } else if(day ==...
CAN YU HELP ME CONSTRUCT A FLOW CHART FOR THE FOLLOW PROGRAM ? C++ CODE: #include<iostream> using namespace std; int main() { //declaring variable num int num; //prompting user to enter a number cout<<"Input a number to check prime or not:"; //reading input from user cin>>num; //loop to check user input for positive number while(num<0) { cout<<"Error! Positive Integers Only.\n"; cout<<"Input a number to check prime or not:"; cin>>num; } //initializing isPrime variable with false bool isPrime = true; //loop...
Hello, I have a bug in my code, and when I run it should ask the user to enter the month and then the year and then print out the calendar for the chosen month and year. My problem with my code is that when I run it and I enter the month, it doesn't ask me for the year and it prints all the years of the month I chose. Please help! Code: #include "calendarType.h" #include <iostream> using namespace...
Help me solve this in C++ Rewrite the code to use array instead of linked lists. Please do not change anything besides the data structure. Instead of linked list use an array. The functionality should remain exactly the same. You can prepare a class if you wish but it is not required. /** * Queue implementation using linked list C style implementation ( no OOP). */ #include <cstdio> #include <cstdlib> #include <climits> #include <iostream> #define CAPACITY 100 // Queue max...
my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip> #include<string> #include "bookdata.h" #include "bookinfo.h" #include "invmenu.h" #include "reports.h" #include "cashier.h" using namespace std; const int ARRAYNUM = 20; BookData bookdata[ARRAYNUM]; int main () { bool userChoice = false; while(userChoice == false) { int userInput = 0; bool trueFalse = false; cout << "\n" << setw(45) << "Serendipity Booksellers\n" << setw(39) << "Main Menu\n\n" << "1.Cashier Module\n" << "2.Inventory Database Module\n" << "3.Report Module\n"...
im writing a c++ code and getting stuck on two parts. The first part, when I go to write the customer order out to the file, it writes everything but the price out right. I'll get a weird number like 5.95828e-039 or nan. When I printout to the console it works fine so not sure what's wrong. Second After I write the order out to the file, I then have to go in and read the file and calculate the...
*** I need help identifying my incoming parameters, outgoing parameters, and return values in the C++ code below. There are 4 functions in the code below and the 3 fields for each function are bolded. Should one of the items not exist, put N/A. **** #include #include using namespace std; int input(long long); // function to Input of Base 2 value to enforce the entry of only 1's and 0's int input2(double); int Base10toBase2(long long); // Base 10 to Base...
need help with java questions
The following snippet of code would produce what outcome? public static void main(String 2 [] args) { int day = 5; switch (day) { case 1: System.out.println("Monday "); case 2: System.out.println("Tuesday "); case 3: System.out.println("Wednesday "); case 4: System.out.println("Thursday "); case 5: System.out.println("Friday "); case 6: System.out.println("Saturday "); case 7: System.out.println("Sunday "); break; default: System.out.println("Invalid Day "); } } Invalid Day Friday Saturday Sunday Invalid Day Friday Friday Saturday Sunday What will be the output...
Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string; class Account { public: Account(); Account(string, double); void deposit(double); bool withdraw(double); string getName() const; double getBalance() const; private: string name; double balance; }; #endif ////////////////////////////////////////////// //AccountManager.hpp #ifndef _ACCOUNT_MANAGER_HPP_ #define _ACCOUNT_MANAGER_HPP_ #include "Account.hpp" #include <string> using std::string; class AccountManager { public: AccountManager(); AccountManager(const AccountManager&); //copy constructor void open(string); void close(string); void depositByName(string,double); bool withdrawByName(string,double); double getBalanceByName(string); Account getAccountByName(string); void openSuperVipAccount(Account&); void closeSuperVipAccount(); bool getBalanceOfSuperVipAccount(double&) const;...