Advertisement
Ramdan51-062

intMain

Sep 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1.     import java.util.Scanner;
  2.     public class intMain
  3.     {
  4.        
  5.         public static void main(String args[])
  6.         {
  7.             Scanner scan = new Scanner(System.in);
  8.             int cost, menu, munny;
  9.             System.out.println("Insert Ticket Price");
  10.             cost = scan.nextInt();
  11.             boolean exit = false;
  12.             TicketMachine ticket = new TicketMachine(cost);
  13.             while(!exit){
  14.             System.out.println("1. Get Price");
  15.             System.out.println("2. Get Balance");
  16.             System.out.println("3. Insert Money");
  17.             System.out.println("4. Print Ticket");
  18.             System.out.println("5. Exit Machine");
  19.             menu = scan.nextInt();
  20.             switch(menu)
  21.             {
  22.                 case 1:
  23.                 cost = ticket.getPrice();
  24.                 System.out.println(cost);
  25.                 System.out.print("\n");
  26.                 break;
  27.                 case 2:
  28.                 munny = ticket.getBalance();
  29.                 System.out.println(munny);
  30.                 System.out.print("\n");
  31.                 break;
  32.                 case 3:
  33.                 int money = scan.nextInt();
  34.                 ticket.addBalance(money);
  35.                 System.out.print("\n");
  36.                 break;
  37.                 case 4:
  38.                 ticket.printTicket();
  39.                 System.out.print("\n");
  40.                 break;
  41.                 case 5:
  42.                 exit = true;
  43.                 break;
  44.             }
  45.         }
  46.         }
  47.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement