Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.59 KB | None | 0 0
  1. public static void main(String[] args) {
  2.  
  3.         Scanner input = new Scanner(System.in);
  4.  
  5.         System.out.println("------------------------------------------------------------");
  6.         System.out.println("------Welcome to the Ticket issuing Management System-------");
  7.         System.out.println("------------------------------------------------------------");
  8.         System.out.print("> Please enter the academic year (ex: 2017-2018) : ");
  9.         String year = input.next();
  10.         System.out.println(" ");
  11.         System.out.print("> How many employees are in year " + year + " :  ");
  12.         int employees = input.nextInt();
  13.         int employeeCount = 0;
  14.        
  15.         String[] ticket_numbers = new String[employees];
  16.         int[] employees_id = new int[employees];
  17.         String[] employees_names = new String[employees];
  18.         String[] ticket_type = new String[employees];
  19.         double[] price = new double[employees];
  20.  
  21.         while (true) {
  22.             displayMainMenu();
  23.             int choice = inputAndCheck();
  24.  
  25.             switch (choice) {
  26.                
  27.                 case 1:
  28.                 case 2:
  29.                    
  30.                     if (employeeCount >= ticket_numbers.length) {
  31.                         System.out.println("> Sorry you have already add all employees");
  32.                         continue;
  33.                     }
  34.                     employeeCount++;
  35.                     int currentIndex2 = employeeCount - 1;
  36.                     System.out.println(" ");
  37.                    
  38.                     if (choice == 1) {
  39.                         ticket_type[currentIndex2] = "local";
  40.                     } else {
  41.                         ticket_type[currentIndex2] = "broad";
  42.                     }
  43.                    
  44.                     System.out.print(" > Enter Ticket Number: ");
  45.                     ticket_numbers[currentIndex2] = input.next();
  46.                     System.out.print(" > Enter emlpyee ID: ");
  47.                     employees_id[currentIndex2] = input.nextInt();
  48.                     System.out.print(" > Enter employee name: ");
  49.                     employees_names[currentIndex2] = input.next();
  50.                     employees_names[currentIndex2] += " " + input.next();
  51.                     System.out.print(" > Enter ticket price: ");
  52.                     price[currentIndex2] = input.nextInt();
  53.                     System.out.println(" ");
  54.                     System.out.println("> Ticket " + ticket_numbers[currentIndex2] + " for employee " + employees_names[currentIndex2] + " has been issued and added to the system.");
  55.                    
  56.                     break;
  57.                 case 3:
  58.                    
  59.                     if (employeeCount == 0) {
  60.                         System.out.println("> *** Cannot remove. There are no tickets currently added in the system.");
  61.                     } else {
  62.                         System.out.println("");
  63.                         System.out.print(" > Enter ticket number: ");
  64.                         String currentTicket = input.next();
  65.  
  66.                         int position = Search(ticket_numbers, currentTicket, employeeCount);
  67.                         if (position == -1) {
  68.                             System.out.println("> ERROR: cannot remove ticek (NO #" + currentTicket + ")\n"
  69.                                     + ">        Ticket was not found in the system.");
  70.                         } else {
  71.                             removeTicket(ticket_numbers,employees_id,employees_names,ticket_type,price,position,employeeCount);
  72.                             System.out.println("> The tickst record has been deleted successfully.");
  73.                         }
  74.  
  75.                     }
  76.                     break;
  77.                 case 4:
  78.                    
  79.                     if (employeeCount == 0) {
  80.                         System.out.println("> *** Cannot print details. There are no tickets currently added in the system.");
  81.                     } else {
  82.                         System.out.println("");
  83.                         System.out.print(" > Enter employee id: ");
  84.                         int id = input.nextInt();
  85.  
  86.                         int employeeId = search(employees_id, id, employeeCount);
  87.                         if (employeeId == -1) {
  88.                             System.out.println("> ERROR: cannot display ticket details for the employee (#" + id + ")");
  89.                             System.out.println(">        Ticket for this employee was not found in the system.");
  90.                         } else {
  91.                             System.out.println("");
  92.                             System.out.println(">>The ticket details is: ");
  93.                             System.out.println(" Ticket No: " + ticket_numbers[employeeId]);
  94.                             System.out.println(" Name: " + employees_names[employeeId]);
  95.                             System.out.println(" Ticket Type: " + ticket_type[employeeId]);
  96.                             System.out.println(" Price: " + price[employeeId]);
  97.                             System.out.println("");
  98.                         }
  99.                     }
  100.                     break;
  101.                 case 5:
  102.                    
  103.                     if (employeeCount == 0) {
  104.                         System.out.println("> *** Cannot print Tickets Statistics. There are no tickets currently added in the system.");
  105.                     } else {
  106.                        
  107.  
  108.                     }
  109.                     break;
  110.                 case 0:
  111.                     System.out.println("");
  112.                     System.out.println("> Thank you for using the Ticket Issuing Management System!");
  113.                     System.out.println("> Goodbye.");
  114.                     System.exit(0);
  115.             }
  116.  
  117.         }
  118.  
  119.     }
  120.  
  121.     public static void displayMainMenu() {
  122.  
  123.         System.out.println("");
  124.         System.out.println("-----------------------------------------------------------\n"
  125.                 + "-------         Ticket Issuing Management System     ------\n"
  126.                 + "-------                     *MAIN MENU*              ------\n"
  127.                 + "-----------------------------------------------------------\n"
  128.                 + "| 1: Enter 1 for Issuing a local Ticket                   |\n"
  129.                 + "| 2: Enter 2 for Issuing a broad Ticket                   |\n"
  130.                 + "| 3: Enter 3 for Removing a Ticket                        |\n"
  131.                 + "| 4: Enter 4 for Printing Ticket for an Employee          |\n"
  132.                 + "| 5: Enter 5 for Printing the Tickets Details             |\n"
  133.                 + "| 0: Enter 0 for Exiting the Program                      |\n"
  134.                 + "-----------------------------------------------------------");
  135.         System.out.print("> Please enter your choice: ");
  136.     } // Done
  137.  
  138.     public static byte inputAndCheck() {
  139.  
  140.         Scanner input = new Scanner(System.in);
  141.         byte choice = input.nextByte();
  142.  
  143.         if (choice > 5) {
  144.             System.out.println("");
  145.             System.out.println("“>Invalid selection! Please\n"
  146.                     + "try again.");
  147.         }
  148.  
  149.         return choice;
  150.     } //Done
  151.  
  152.     public static int search(int[] emId, int employeeid, int employeeCount) {
  153.  
  154.         int results = -1;
  155.         for (int i = 0; i < employeeCount; i++) {
  156.             if (emId[i] == employeeid) {
  157.                 results = i;
  158.                 break;
  159.             }
  160.  
  161.         }
  162.  
  163.         return results;
  164.     } // Done
  165.  
  166.     public static int Search(String[] tickets, String ticket, int employeeCount) {
  167.  
  168.         int results = -1;
  169.         for (int i = 0; i < employeeCount; i++) {
  170.             if (tickets[i].equalsIgnoreCase(ticket)) {
  171.                 results = i;
  172.             }
  173.         }
  174.  
  175.         return results;
  176.     } // Done
  177.  
  178.     public static void removeTicket(String[] tickets, int[] emId, String[] employees_names,
  179.             String[] tickettype, double[] price, int position,int employeeCount) {
  180.        
  181.        
  182.        
  183.        
  184.     }
  185.  
  186.     public static double displayTicketsInformation(String[] tickets, int[] emId, String[] employees_names,
  187.             String[] tickettype, double[] price, String ticket_Type, int employeeCount) {
  188.  
  189.         System.out.println("Ticket Details based on Ticket Type");
  190.         System.out.println("===================================================================================");
  191.         System.out.println("");
  192.         System.out.println("===================================================================================");
  193.         System.out.println("");
  194.  
  195.         return 0;
  196.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement