Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /*
- ==================================================
- NoteBook chapter 1: language building stones
- Ex2: Toast order
- ==================================================
- */
- public class MyProgram {
- public static void main(String[] args) {
- //variables
- final int TOAST_PRICE=12;
- final int CHEAP_EXTRA=2;
- final int EXPENSIVE_EXTRA=3;
- int totalCheap,totalExp;
- Scanner s=new Scanner(System.in);
- int totalPrice;
- //printing menu- optional: only for display
- System.out.println("\n\t===================\n\t\tToast Menu\n\t===================");
- System.out.println("Tost Price: "+TOAST_PRICE+"ILS\n");
- System.out.print("cheap 2 ILS\t|\texpensive 3 ILS\n-----------------------------------\n");
- System.out.print("tomatoes\t|\tExstra hard cheese\nolives\t\t|\tBulgarian cheese\n" +
- "mushrooms\t|\tcream cheese\ncorn\t\t|\thard cooked egg\n" +
- "onion\t\t|\teggplant\npeppers\t\t|\ttuna\n\n");
- //user input
- System.out.println("\nhow many cheap extras do you want? ");
- totalCheap=s.nextInt();
- System.out.println("how many Expensive extras?");
- totalExp=s.nextInt();
- //calc price to pay
- totalPrice=( TOAST_PRICE + (CHEAP_EXTRA*totalCheap) + (EXPENSIVE_EXTRA*totalExp) );
- System.out.println("price to pay: "+ totalPrice+" ILS");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment