Author: Not specified Language: text
Description: Not specified Timestamp: 2017-06-27 19:57:52 +0000
View raw paste Reply
  1. import java.util.*;
  2. public class Project{
  3.     static Scanner sc = new Scanner(System.in);
  4.     static Movie movies[] = new Movie[100];
  5.     static int n = 0;
  6.     public static void main(){
  7.         scr1();
  8.     }
  9.     public static void scr1(){
  10.         System.out.println("1. System Update");
  11.         System.out.println("2. List of movies with show timings");
  12.         System.out.println("3. Book a ticket");
  13.         System.out.println("4. Exit");
  14.         System.out.println("Choose an option.");
  15.         int op = sc.nextInt();
  16.         System.out.print("\u000c");
  17.         switch(op){
  18.             case 1: sysup();
  19.             break;
  20.             case 2:movtim();
  21.             break;
  22.             case 3:booktick();
  23.             break;
  24.             case 4: exit();
  25.             break;
  26.             default : System.out.println("Wrong option.");scr1();
  27.         }
  28.     }
  29.     public static void sysup(){
  30.        
  31.         System.out.println("1. Add a new movie");
  32.         System.out.println("2. Update movie/show timings");
  33.         System.out.println("3. Delete a movie");
  34.         System.out.println("4. Return to previous menu");
  35.         System.out.println("5. Exit");
  36.         System.out.println("Choose an option.");
  37.         int op = sc.nextInt();
  38.         System.out.print("\u000c");
  39.         switch(op){
  40.             case 1: newmov();
  41.             break;
  42.             case 2: showtim();
  43.             break;
  44.             case 3: delmov();
  45.             break;
  46.             case 4: scr1();
  47.             break;
  48.             case 5: exit();
  49.             break;
  50.             default : System.out.println("Wrong option.");
  51.             sysup();
  52.         }
  53.     }
  54.     public static void disp(){
  55.         try{
  56.             System.out.println("Name\t\t\tTiming\t\t\t\tAudi\t\t\tSeats available\t\t\tprice - first class\t\t\tprice - second class\t\t\tprice - third class\t\t\tLanguage");
  57.             for(int i = 0;i<n+1;i++){
  58.                 if(movies[i]!=null){
  59.                 System.out.print(movies[i].name);
  60.                 for(int h = 0;h<24-movies[i].name.length();h++,System.out.print(" ")){}
  61.                 System.out.println(movies[i].timing[0].formatteddate() + "\t\t" + movies[i].audi[0]  +"\t\t\t"+ movies[i].tickets[0]+ "\t\t\t\t" + movies[i].amountf[0] + "\t\t\t\t\t" + movies[i].amounts[0] + "\t\t\t\t\t" + movies[i].amountt[0] + "\t\t\t\t\t" + movies[i].lang);
  62.                 for(int j = 1;j<movies[i].timing.length;j++){
  63.                     System.out.println("\t\t\t" + movies[i].timing[j].formatteddate() + "\t\t" + movies[i].audi[j] +"\t\t\t"+movies[i].tickets[j]+ "\t\t\t\t" + movies[i].amountf[j] + "\t\t\t\t\t" + movies[i].amounts[j] + "\t\t\t\t\t" + movies[i].amountt[j]);
  64.                 }
  65.             }
  66.             }
  67.         }catch(Exception e){
  68.         }
  69.     }
  70.     public static void movtim(){
  71.         disp();
  72.         scr1();
  73.     }
  74.     public static void booktick(){
  75.         disp();
  76.         System.out.println("\n\n\n");
  77.         System.out.println("Which movie would you like to go for?");
  78.         sc.nextLine();
  79.         String movname = sc.nextLine();
  80.         System.out.println("Enter  date in format ddmmyyyy");
  81.         String inp = sc.next();
  82.         int day = Integer.parseInt("" + inp.charAt(0) + inp.charAt(1));
  83.         int month = Integer.parseInt("" + inp.charAt(2) + inp.charAt(3));
  84.         int year = Integer.parseInt("" + inp.charAt(4) + inp.charAt(5) + inp.charAt(6) + inp.charAt(7));
  85.         System.out.println("Enter preferred showtime in 24 hour format - hhmm");
  86.         inp = sc.next();
  87.         int hour = Integer.parseInt("" + inp.charAt(0) + inp.charAt(1));
  88.         int min = Integer.parseInt("" + inp.charAt(2) + inp.charAt(3));
  89.         System.out.println("Enter 1 for first class.");
  90.         System.out.println("Enter 2 for second class.");
  91.         System.out.println("Enter 3 for third class.");
  92.         int cl = sc.nextInt();
  93.         System.out.println("How many tickets would you like to book?");
  94.         int num = sc.nextInt();
  95.         int mov=0;
  96.         int tim=0;
  97.         int totalamount=0;
  98.         for(int i = 0;movies[i].name.equalsIgnoreCase(movname) == false;i++,mov=i){}
  99.         for(int i = 0;movies[mov].timing[i].day!=day||movies[mov].timing[i].month!=month||movies[mov].timing[i].year!=year||movies[mov].timing[i].hour!=hour||movies[mov].timing[i].min!=min;i++,tim=i){}
  100.         switch(cl){
  101.             case 1: totalamount = num * movies[mov].amountf[tim];
  102.                     break;
  103.             case 2: totalamount = num * movies[mov].amounts[tim];
  104.                     break;
  105.             case 3: totalamount = num * movies[mov].amountt[tim];
  106.                     break;
  107.         }
  108.         System.out.println("\u000c");
  109.         if(movies[mov].tickets[tim]>=num){
  110.             System.out.println("  ______________________________________________________");
  111.             System.out.println(" |                   Movie Ticket                        |");
  112.             System.out.println(" |                                                       |");
  113.             System.out.print(" | Movie - "+movies[mov].name);

This paste is large and only partially shown.
View full paste

View raw paste Reply