Problem 2: Point of Sale System The McDowell Restaurant chain has asked you to s
ID: 3754564 • Letter: P
Question
Problem 2: Point of Sale System The McDowell Restaurant chain has asked you to service machines. Your program already prints the write a menu program for their new Fast-food following menu like this: McDowe11's Restaurant Make your selection from the menu below: 1. Regular Hamburger $1.se 2. Regular Cheeseburger $1.75 3. Fish Sandwich $2.se 4. Half-pounder with cheese $2.75 5. French Fries $e.99 6. Large Soft Drink $1.25 Select 1, 2, 3, 4, 5, or 6 > Your purchase, including 6.5% sales tax. program must now read the customer's selection and compute the total price of their Input The first line of input represents N, the number of items to be second line consists of the sequence of N numbers scoped between 1 to 6. Each number should indicate a selection from the above menu to be purchased. entered into the POs system. The Output The program should print the sum of the orders plus tax as "Please pay $", where dollars is the total amount of the purchase then conclude with "Thank you for eating at McDowell's Sample Input Sample Output 6 144531 Please pay $12.77 Thank you for eating at McDowell'slExplanation / Answer
Edited Answer:
As requested in the comment here is the java program of the same problem :
=======================================================================================
import java.util.Scanner;
public class McDowell{
public static void main(String[] args) {
int currSelection=0;
float amount=0;
System.out.println(" *********************************************************");
System.out.println(" McDowell's Restaurant");
System.out.println(" *********************************************************");
System.out.println(" Make your selection from the menu below:");
System.out.println(" 1. Regular Hamburger $1.50 2. Regular Cheeseburger $1.75 3. Fish Sandwich $2.50 4. Half-pounder with cheese $2.75 5. French Fries $0.99 6. Large Soft Drink $1.25");
System.out.println(" *********************************************************");
System.out.println(" Select 1, 2, 3, 4, 5 or 6 ----->");
Scanner in = new Scanner(System.in);
int N = in.nextInt(); //Number of items get input into N here
int choices = in.nextInt(); //Enter your choices and press enter- numbers among 1 to 6 (without space), any other input than amoing 1 to 6 will be ignored as a choice
while(choices!=0)
{
currSelection = choices % 10;
choices /= 10;
switch( currSelection ){
case 1:
amount += 1.5;
break;
case 2:
amount += 1.75;
break;
case 3:
amount += 2.5;
break;
case 4:
amount += 2.75;
break;
case 5:
amount += 0.99;
break;
case 6:
amount += 1.25;
break;
default:
break;
}
}
amount += (amount * 6.5)/100 ; //adding sales tax of 6.5 % here
System.out.printf(" Please pay $%.2f ", amount);
System.out.println(" Thank you for eating at McDowell's!");
}
}
====================================================================================
Original Answer:
Here is the required c++ code for the given problem. In case of any queries do write me the comments.
=====================================================================
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int N=0, choices=0, currSelection=0;
float amount=0;
cout<<" *********************************************************";
cout<<" McDowell's Restaurant";
cout<<" *********************************************************";
cout<<" Make your selection from the menu below:";
cout<<" 1. Regular Hamburger $1.50 2. Regular Cheeseburger $1.75 3. Fish Sandwich $2.50 4. Half-pounder with cheese $2.75 5. French Fries $0.99 6. Large Soft Drink $1.25";
cout<<" *********************************************************";
cout<<" Select 1, 2, 3, 4, 5 or 6 ----->";
cin>>N; //Enter the number of items
cin>>choices; //Enter your choices and press enter- numbers among 1 to 6 (without space), any other input than amoing 1 to 6 will be ignored as a choice
while(choices)
{
currSelection = choices % 10;
choices /= 10;
switch( currSelection ){
case 1:
amount += 1.5;
break;
case 2:
amount += 1.75;
break;
case 3:
amount += 2.5;
break;
case 4:
amount += 2.75;
break;
case 5:
amount += 0.99;
break;
case 6:
amount += 1.25;
break;
default:
break;
}
}
amount += (amount * 6.5)/100 ; //adding sales tax of 6.5 % here
cout << fixed; //To format the float representation of final amount in bill
cout << setprecision(2);
cout<<" Please pay $"<<amount;
cout<<" Thank you for eating at McDowell's!";
}
======================================================================
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.