PLZ Need some help on the 2nd part of this question...Someone please help !!!!



Share on Google+Share on Google+

PLZ Need some help on the 2nd part of this question...Someone please help !!!!
1 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners

write an application that displays a menue of three items in a restaurant as follows: 1.Cheeseburger 4.99 2.Pepsi 2.00 3.Chips 0.75 prompt the user to choose an item using the number (1,2,or 3) that corresponds to the item, or to enter 0 to quit the application.after the user makes the first selection, if the choice is 0, display a bill of $0.otherwise,display the menu again.the user should respond to this prompt with another item number to order or 0 to quit.if the user types0,display the cost of the single requested item.if the user types 1,2 or 3 add the cost of the second item to the first, and then display the menu a third time.if the user types 0 to quit,display the total cost of the two items;otherwise,display the total for all three the file as

B. modify the application in Exercise above so that if the user makes a menu selection he or she has already made, ignore the selection-that is,do not add a second price for the same item to the total.the user is still allowed only three the file as

View Answers

September 22, 2011 at 12:46 PM

import java.util.Scanner;
 class FastFood
  public static double check1 = 0.0;
  public static double check2 = 0.0;
  public static double check3 = 0.0;
    public static double order()
    int selection;
     System.out.println("(1) Cheeseburger 4.99");
     System.out.println("(2) Pepsi        2.00");
     System.out.println("(3) Chips        0.75");

     Scanner input = new Scanner(;

     System.out.println("\nWhich item would you like to order?");
     selection = input.nextInt();

     if(selection == 1)
        check1 = 4.99;  
        return 4.99;
     else if (selection == 2)
       check2 = 2.00;
       return 2.00;
     else if (selection == 3)
       check3 = 0.75;  
        return 0.75;
       return 0;
public class FastFood2 {

  public static void main(String[] args)
      FastFood food=new FastFood();
    double foodTotal = 0.0;
     double item1 = 0.0;
     double item2 = 0.0;
     double item3 = 0.0;

     item1 = food.order();
     if ((item1 > 0) && (food.check1 != 4.99) || (food.check2 != 2.00) || (food.check3 != 0.75))
       item2 = food.order();
     if ((item2 > 0) && (food.check1 != 4.99) || (food.check2 != 2.00) || (food.check3 != 0.75))
       item3 = food.order();

     foodTotal = food.check1 + food.check2 + food.check3;
     System.out.println("Total Bill is: $" + foodTotal);



Related Tutorials/Questions & Answers:
Java Spring Hibernate Struts Training ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java


Advertisement null