Fix this code please #include #include #include #include Using namespace std; //Structure to hold each menu item Struct Menultem. { String name; Double price; }; //Function that reads data from file Int getData(struct Menultem menuList[]) { //Opening file for reading Fstream fin("menu.txt", ios::in); Int i=0; Struct Menultem temp; //Loop till entire data is processed While(fin.good()) { //Getting name Getline(fin, temp.name); //Reading price Fin >> temp.price; Fin.ignore(); //Storing in array menuList[i] = temp; i++; } //Closing file Fin.close(); Return i; } //Function that displays menu Void showMenu(struct Menultem menuList[], int cnt) Int i; Cout<<"\n Welcome to the Programmers' Cafe \n\n-Today's Menu--------\n"; //Looping over menu and printing to user For(i=0; i> ch; //Loop till user wants to stop While(ch == 'y' || ch == 'Y') { //Reading item number Cout << "\n\n Enter item number: "; Cin >> temp; While(temp <1 || temp > cnt) { //Reading item number. Cout<<"\n\n Enter item number between 1 and " << cnt << ": "; Cin >> temp; } //Storing in array Item[i] = temp; //Reading item quantity Cout << "\n Enter item quantity: "; Cin >> temp; //Storing in array Quantity[i] temp; //Prompting user again Cout << "\n\n Select another item? (y/n): "; Cin >> ch; } Return i; } //Function that calculates the price Void priceCheck(struct Menultem menuList[], int item[], int quantity[], int items) { Int i=0; Double total = 0, tax; Cout << "\n\n Thank you for eating at The Programmers' Cafe\n\n"; Cout << " Cout << "\n" << left <

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Fix this code please

#include <iostream>

#include <iomanip>

#include <fstream>

#include <string>

Using namespace std;

//Structure to hold each menu item

Struct Menultem.

{

String name;

Double price;

};

//Function that reads data from file Int getData(struct Menultem menuList[]) {

//Opening file for reading

Fstream fin("menu.txt", ios::in);

Int i=0;

Struct Menultem temp;

//Loop till entire data is processed While(fin.good())

{

//Getting name

Getline(fin, temp.name);

//Reading price

Fin >> temp.price;

Fin.ignore();

//Storing in array

menuList[i] = temp;

i++;

}

//Closing file

Fin.close();

Return i;

}

//Function that displays menu

Void showMenu(struct Menultem menuList[], int cnt)

Int i;

Cout<<"\n Welcome to the Programmers' Cafe \n\n-Today's Menu--------\n";

//Looping over menu and printing to user

For(i=0; i<cnt; i++)

{

//Printing menu item

Cout << fixed << setprecision(2];

Cout << "\n" << right <<setw(3) << (i+1) << " " << left <<setw(25) << menuList[i].name << left << setw(2) << "$" << left <<setw(10) << menuList[i].price;

}

Cout << "\n \n";

}

//Function that reads user selection

Int makeSelection(int item[], int quantity[], int cnt)

Int i=0, temp;

Char ch;

//Prompting user

Cout << "\n\n Do you want place an order? (y/n): ";

Cin >> ch;

//Loop till user wants to stop

While(ch == 'y' || ch == 'Y')

{

//Reading item number

Cout << "\n\n Enter item number: ";

Cin >> temp;

While(temp <1 || temp > cnt)

{

//Reading item number.

Cout<<"\n\n Enter item number between 1 and " << cnt << ": ";

Cin >> temp;

}

//Storing in array

Item[i] = temp;

//Reading item quantity

Cout << "\n Enter item quantity: ";

Cin >> temp;

//Storing in array

Quantity[i] temp;

//Prompting user again

Cout << "\n\n Select another item? (y/n): ";

Cin >> ch;

}

Return i;

}

//Function that calculates the price

Void priceCheck(struct Menultem menuList[], int item[], int quantity[], int items)

{

Int i=0;

Double total = 0, tax;

Cout << "\n\n Thank you for eating at The Programmers' Cafe\n\n";


Cout << "

Cout << "\n" << left <<setw(20) << "Receipt" << left <<setw(5) << "Qty" << left <<setw(5) << "Amount

\n";

Cout<<

-\n";

Cout << fixed << setprecision(2);

//Printing menu selected

For(i=0; i<items; i++)

Cout << "\n" << left <<setw(20) << menuList[item[i] -1].name << left <<setw(5) << quantity[i] << left <<setw(2) << "$" << left <<setw(2) << (quantity[i]* (menuList[item[i] -1].price]);

Total += (quantity[i]* (menuList[item[i] - 1].price));

}

//Calculating tax

Tax (7/100.0) * total;

//Printing tax

Cout << "\n\n" << left <<setw(25) << "Tax " << left <<setw(2) << "$" << left <<setw(2) << tax;

//Printing total amount due

Cout << "\n\n" << left <<setw(25) << "Amount Due " << left <<setw(2) << "$" << left <<setw(2) << (total + tax) << "\n\n";

}

//Main function

Int main()

Struct Menultem menuList[10];

Int item[20], quantity[20];

Int totalltems, cnt;

//Reading data

Cnt= getData(menuList);

//Displaying menul

showMenu(menuList, cnt);

//Making user selection.

totalltems makeSelection(item, quantity, cnt);

//Checking price

priceCheck(menuList, item, quantity, totalltems);

cout << "\n\n";

return 0;

}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY