Question

In: Computer Science

answer in basic JAVA im in and INTRO JAVA CLASS Problem 2: Point of Sale System...

answer in basic JAVA im in and INTRO JAVA CLASS

Problem 2: Point of Sale System
The McDowell Restaurant chain has asked you to write a menu program for their new Fast-food
service machines. Your program already prints the following menu like this:
**********************************************************************
McDowell’s Restaurant
**********************************************************************
Make your selection from the menu below:
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
***********************************************************************
Select 1, 2, 3, 4, 5, or 6 ----- >
Your program must now read the customer’s selection and compute the total price of their
purchase, including 6.5% sales tax.


Input
The first line of input represents N, the number of test cases. The additional lines consists of a
sequence of integers scoped between 1 to 6. Each number should indicate a selection from the
above menu to be purchased.


Output
The program should print the sum of the orders plus tax as “Please pay $<dollars>”, where
<dollar> is the total amount of the purchase then conclude with “Thank you for eating at
McDowell’s”.


Sample Input Sample Output
1
1 4 4 5 3 1 Please pay $12.77
Thank you for eating at McDowell’s!

Solutions

Expert Solution

import java.util.Scanner;
import java.util.*;
import java.io.*;
import java.text.DecimalFormat;

public class Restaurant
{
   //set the number of decimal places
private static DecimalFormat df = new DecimalFormat("0.00");
//driver program
public static void main(String[] args)
{
   //create the scanner object
Scanner scnr = new Scanner(System.in);
int i=0,n,j;
int a[] = new int[50];
double price=0,tax=0;
//declare and initialize the values of prices
double p[]={1.5,1.75,2.5,2.75,0.99,1.25};
//ask for number of test cases
System.out.println("Enter how many test cases do you want ? ");
n=scnr.nextInt();
//loop for number of test cases
while(n>0)
{
price=0; //set price to 0 for all test cases
//display the menu
System.out.println("******************************************");
System.out.println("1. Regular Hamburger $1.50");
System.out.println("2. Regular Cheeseburger $1.75");
System.out.println("3. Fish Sandwich $2.50");
System.out.println("4. Half - Pounder with cheese $2.75");
System.out.println("5. French Fries $0.99");
System.out.println("6. Large Soft Drink $1.25");
System.out.println("******************************************");
System.out.println("Enter the options,Enter 0 to stop");
//read the options
for(i=0;;i++)
{
a[i]=scnr.nextInt();

if(a[i]==0)//loop terminating condition
break;

//condition for invalid entry

if(a[i]<1 || a[i]>6)
{
   System.out.println("Invalid choice");
   i--;
}  
}
//compute the total price
for(j=0;j<i;j++)
{

price = price + (p[a[j]-1]);
}
//add the tax to price
price = price + (price * 0.065);
//deiplay the total amount
System.out.println("Please pay $"+df.format(price));
n--; //decrease n for nexxt test cases
}
//display the message
System.out.println("Thank you for eating McDowell's!");
}
}

output


Related Solutions

This is an intro to java question. Please answer with pseudocode and code. Problem 2: RSA...
This is an intro to java question. Please answer with pseudocode and code. Problem 2: RSA Public Key (10 points) (Cyber Security) RSA is an asymmetric encryption scheme, where a public key is used to encrypt data and a different, private key decrypts that data. RSA public/private keys are generated from two prime numbers, typically very large ones. The idea behind RSA is based on the fact that its difficult to factorize very large integers. RSA public key generation is...
This is an intro to java question. Please post with pseudocode and java code. Problem should...
This is an intro to java question. Please post with pseudocode and java code. Problem should be completed using repetition statements like while and selection statements. Geometry (10 points) Make API (API design) Java is an extensible language, which means you can expand the programming language with new functionality by adding new classes. You are tasked to implement a Geometry class for Java that includes the following API (Application Programming Interface): Geometry Method API: Modifier and Type Method and Description...
JAVA Point of Sale System The McDowell Restaurant chain has asked you to write a menu...
JAVA Point of Sale System The McDowell Restaurant chain has asked you to write a menu program for their new Fast-food service machines. Your program already prints the following menu like this: ********************************************************************** McDowell’s Restaurant ********************************************************************** Make your selection from the menu below: 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 *********************************************************************** Select 1, 2, 3, 4, 5, or 6 ----- >...
The problem is below. This is for an intro to Python class, so, if possible keep...
The problem is below. This is for an intro to Python class, so, if possible keep it relatively simple and 'basic.' The code in bold below is given: def trade_action(current_stock, purchase_price, current_price, investment): # Write your code here. return "Hold Shares." Instructions: Many investment management companies are switching from manual stock trading done by humans to automatic stock trading by computers. You've been tasked to write a simple automatic stock trader function that determines whether to buy, sell, or do...
Im in a java class and having trouble with assigning the seat to a specific number...
Im in a java class and having trouble with assigning the seat to a specific number from the array.. Below are the instructions I was given and then the code that I have already.   ITSE 2321 – OBJECT-ORIENTED PROGRAMMING JAVA Program 8 – Arrays and ArrayList A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You are to write an application to assign seats on flight...
1. Point-of-Sale System: We have two companies that can implement a point-of-sale system. Both with cost...
1. Point-of-Sale System: We have two companies that can implement a point-of-sale system. Both with cost $200,000 to implement. Company A says we will receive the following returns on our investment: Year 1: $85,000; Year 2: $25,000; Year 3: $30,000; Years 4–10: $10,000. Company B says we will receive the following returns on our investment: Year 1: $30,000; Year 2: $25,000; Year 3: $85,000; Years 4–10: $10,000. Using the payback method, which company should we use and Why?
//JAVA //basic please for learning programming 2. Thank you. Write the Class Variables Class Box is...
//JAVA //basic please for learning programming 2. Thank you. Write the Class Variables Class Box is to have the following private data members: height of type double width of type double length of type double Write the following Overridden Method Class Box is to have an overridden equals() method that does the following:​​​​ tests to see if the parameter represents an object (null test) tests to see if the parameter object is of the same class type as the calling...
Intro to java Problem, Please provide code and Pseudocode. Not able to compile correct numbers. Problem...
Intro to java Problem, Please provide code and Pseudocode. Not able to compile correct numbers. Problem 7: Simple Calculator (10 points) (General) Calculators represent the most basic, general-purpose of computing machines. Your task is to reduce your highly capable computer down into a simple calculator. You will have to parse a given mathematical expression, and display its result. Your calculator must support addition (+), subtraction (-), multiplication (*), division (/), modulus(%), and exponentiation (**). Facts ● Mathematical expressions in the...
This is an Intro to java question. Please provide code and pseudocode for better understanding. Problem...
This is an Intro to java question. Please provide code and pseudocode for better understanding. Problem 4: Player Move Overworld (10 points) (Game Development) You're the lead programmer for an indie game studio making a retro-style game called Zeldar. You've been tasked to implement the player movement. The game is top-down, with the overworld modeled as a 2d grid. The player's location is tracked by x,y values correlating to its row and column positions within that grid. Given the current...
This is an Intro to Java Question, Please respond with code and pseudocode. Problem 3: RSA...
This is an Intro to Java Question, Please respond with code and pseudocode. Problem 3: RSA Private Key (10 points) (Cyber Security) In the RSA algorithm, encrypting and decrypting a message is done using a pair of numbers that are multiplicative inverses with respect to a carefully selected modulus. In this task, you must calculate the modular multiplicative inverse for given set of values. What is the Modular Multiplicative Inverse? In mathematics, each operation typically has an inverse. For example,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT