Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class order{
- public static void main(String[] args){
- char choice;
- Scanner unit = new Scanner(System.in);
- System.out.print("Welcome to a Generic Fast Food Restaurant. What would you like to order?");
- do{
- System.out.print( "\n\n1. Hamburger - $0.78"
- + "\n2. Cheeseburger - $1.13"
- + "\n3. Frenchfries - $0.97"
- + "\n4. Fried Chicken - $1.75"
- + "\n5. Chicken Nuggets - $2.17"
- + "\n6. Hotcakes - $1.46"
- + "\nPlease type the number of the order you want"
- + "\n\n>> ");
- int order = unit.nextInt();
- double total = calculateTotal(order);
- System.out.print("\nYour change is " + total + ". Thank you for ordering with a Generic Fast Food Restaurant."
- + "\nWould you like to place another order? (Y/N) >> ");
- choice = unit.next().charAt(0);
- }while (choice == 'Y' || choice == 'y');
- System.out.println("Thank you for ordering with a Generic Fast Food Restaurant. Goodbye!");
- }
- public static double calculateTotal(int order) {
- Scanner unit = new Scanner(System.in);
- double drink = 1.32;
- double cost = 0.0;
- double itemCost = 0.0;
- switch (order) {
- case 1:
- itemCost = 0.78;
- break;
- case 2:
- itemCost = 1.13;
- break;
- case 3:
- itemCost = 0.97;
- break;
- case 4:
- itemCost = 1.75;
- break;
- case 5:
- itemCost = 2.17;
- break;
- case 6:
- itemCost = 1.46;
- break;
- default:
- System.out.print("\nInvalid Command. Please only choose one");
- }
- System.out.print("Would you like to add a drink to your order for only $1.32? >> ");
- char choice = unit.next().charAt(0);
- if (choice == 'Y' || choice == 'y') {
- cost = itemCost + drink;
- } else {
- cost = itemCost;
- }
- System.out.print("Thank you for ordering your total is " + cost + "\n How much are you paying? >> ");
- double money = unit.nextDouble();
- return money - cost;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement