Source of GreesieBurger.java


  2: import java.util.Scanner;

  4: /**
  5:  * A simple order-taking app to demonstrate the "if" control
  6:  *
  7:  * @author Mark Young (A00000000)
  8:  * @version 1.1 2014-09-08
  9:  */
 10: public class GreesieBurger {

 12:     public static void main(String[] args) {
 13:         // create variables
 14:         Scanner kbd = new Scanner(System.in);
 15:         String answer;
 16:         double amount = 0.00;

 18:         // welcome customer
 19:         System.out.print("\n\n"
 20:                 + "Welcome to GreesieBurger!\n"
 21:                 + "-------------------------\n\n");

 23:         // ask for sandwich order
 24:         System.out.print("What sandwich would you like? ");
 25:         answer = kbd.nextLine();
 26:         System.out.println(answer.toUpperCase() + "!");
 27:         System.out.println("(" + answer.toLowerCase() + ")");
 28:         amount += 8.95;

 30:         // ask if want fries
 31:         System.out.print("Would you like fries with that? ");
 32:         answer = kbd.nextLine();
 33:         if (answer.toLowerCase().startsWith("yes")) {
 34:             System.out.println("FRIES!");
 35:             System.out.println("(fries)");
 36:             amount += 2.99;
 37:         }

 39:         // ask for drink order
 40:         System.out.print("What can I get you to drink? ");
 41:         answer = kbd.nextLine();
 42:         System.out.println(answer.toUpperCase() + "!");
 43:         System.out.println("(" + answer.toLowerCase() + ")");
 44:         amount += 2.99;

 46:         // report back order and total amount owed
 47:         System.out.print("\n"
 48:                 + "That'll be $" + amount + ".\n\n");
 49:         System.out.println("Thank-you for eating at GreesieBurgers!\n");
 50:     }

 52: }