Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How write a program using functions program needs to output this Welcome to Happ

ID: 3723916 • Letter: H

Question

How write a program using functions program needs to output this Welcome to Happy Burger 1. Place Order 2. Exit Program Enter choice: 1 Place your order 1. Burger 2. Cheese Burger 3. Hot Dog 4. French Fries 5. Fountain Drink 6. Check Out Enter choice: 1 Enter choice: 3 Enter choice: 4 Enter choice: 5 Enter choice: 5 Enter choice: 6 ************ ** ********* ** Burger 2.00 Hot Dog 1.50 French Fry 1.00 Drink 0.75 Drink 0.75 ------------------------- Total: 6.00 *** Thank You *** Welcome to Happy Burger 1. Place Order 2. Exit Program Enter choice:

Explanation / Answer

import java.util.Scanner;

public class HappyBurger {

   public HappyBurger() {

       // TODO Auto-generated constructor stub

   }

  

   public static void order()

   {

       int order;

       Scanner sc = new Scanner(System.in);

       double totalAmount = 0;

       boolean checkOut = false;

       while(!checkOut){

           System.out.println("1. Burger 2. Cheese Burger 3. Hot Dog 4. French Fries 5. Fountain Drink 6. Check Out ");

           order = sc.nextInt();

           if(order == 6){

               System.out.println("Total: " + totalAmount);

               System.out.println("Thank You");

               checkOut = true;

           }

           if(order == 1){

               totalAmount += 2;

           }

           if(order == 2){

               totalAmount += 2;

           }

           if(order == 3){

               totalAmount += 1.5;

           }

           if(order == 4){

               totalAmount += 1;

           }

           if(order == 5){

               totalAmount += 0.75;

           }

          

       }

       sc.close();

  

   }

   public static void main(String[] args){

      

       boolean exit = false;

       Scanner sc = new Scanner(System.in);

       int choice;

      

       while(!exit){

           System.out.println("Welcome to Happy Burger 1. Place Order 2. Exit Program Enter choice:");

           choice = sc.nextInt();

           if(choice == 2){

               exit = true;

           }

           else if(choice == 1){

               order();

           }

       }

       sc.close();

   }

}

Sample output:

Welcome to Happy Burger 1. Place Order 2. Exit Program Enter choice:

1

1. Burger 2. Cheese Burger 3. Hot Dog 4. French Fries 5. Fountain Drink 6. Check Out

1

1. Burger 2. Cheese Burger 3. Hot Dog 4. French Fries 5. Fountain Drink 6. Check Out

4

1. Burger 2. Cheese Burger 3. Hot Dog 4. French Fries 5. Fountain Drink 6. Check Out

6

Total: 3.0

Thank You

Welcome to Happy Burger 1. Place Order 2. Exit Program Enter choice:

2

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote