0% found this document useful (0 votes)
28 views2 pages

Document

The document contains code for a Java program that calculates the total cost of items ordered from an In-N-Out Burger menu. The program prompts the user to enter quantities of hamburgers, cheeseburgers, fries and drinks, calculates subtotals and a grand total, and identifies the most expensive item.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Document

The document contains code for a Java program that calculates the total cost of items ordered from an In-N-Out Burger menu. The program prompts the user to enter quantities of hamburgers, cheeseburgers, fries and drinks, calculates subtotals and a grand total, and identifies the most expensive item.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

Scanner;

import java.text.NumberFormat;

import java.util.Locale;

public class MyClass {

public static void main(String args[]) {

Scanner sc=new Scanner(System.in);

System.out.println("Welcome to the In-N-Out Burger menu:");

System.out.println("------------------------------------------------------");

System.out.println("Hamburger $2.75");

System.out.println("Cheeseburger $3.25");

System.out.println("French Fries $2.50");

System.out.println("Shake & Beverage: $1.50");

System.out.println("How many hamburger(s) would you like to buy?");

int hb=sc.nextInt();

System.out.println("How many cheeseburger(s) would you like to buy?");

int cb=sc.nextInt();

System.out.println("How many French fries would you like to buy?");

int ff=sc.nextInt();

System.out.println("How many drinks would you like to buy?");

int d=sc.nextInt();

double HAM=2.75;

double CHEESE=3.25;

double FRIES=2.50;

double DRINKS=1.50;

NumberFormat dollars = NumberFormat.getCurrencyInstance();


System.out.println("The total cost for the hamburger(s) = "+dollars(HAM*hm));

System.out.println("The total cost for the cheeseburger(s) = "+dollars(CHEESE*cb));

System.out.println("The total cost for fries = "+dollars(FRIES*ff));

System.out.println("The total cost for drink(s) = "+dollars(DRINKS*d));

String highest="";

if(HAM*hm>CHEESE*cb && HAM*hm>DRINKS*d && HAM*hm>FRIES*ff){

highest="Hamburger(s)";

else if(HAM*hm<CHEESE*cb && CHEESE*cb>DRINKS*d && CHEESE*cb>FRIES*ff){

highest="Cheeseburger(s)";

else if(DRINKS*>CHEESE*cb && HAM*hm<DRINKS*d && DRINKS*>FRIES*ff){

highest="Drinks"

else if(FRIES*ff>CHEESE*cb && FRIES*ff>DRINKS*d && HAM*hm<FRIES*ff){

highest="French fries";

System.out.println("Item that had the highest total cost is "+highest);

System.out.println("The total cost for the order = "+dollars(HAM*h+CHEESE*cb+FRIES*f+DRINKS*));

System.out.println("The total number of hamburgers, cheeseburgers, French fries, and drinks ordered =
");

You might also like