Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("------------------------------------------------------------");
- System.out.println("------Welcome to the Ticket issuing Management System-------");
- System.out.println("------------------------------------------------------------");
- System.out.print("> Please enter the academic year (ex: 2017-2018) : ");
- String year = input.next();
- System.out.println(" ");
- System.out.print("> How many employees are in year " + year + " : ");
- int employees = input.nextInt();
- int employeeCount = 0;
- String[] ticket_numbers = new String[employees];
- int[] employees_id = new int[employees];
- String[] employees_names = new String[employees];
- String[] ticket_type = new String[employees];
- double[] price = new double[employees];
- while (true) {
- displayMainMenu();
- int choice = inputAndCheck();
- switch (choice) {
- case 1:
- case 2:
- if (employeeCount >= ticket_numbers.length) {
- System.out.println("> Sorry you have already add all employees");
- continue;
- }
- employeeCount++;
- int currentIndex2 = employeeCount - 1;
- System.out.println(" ");
- if (choice == 1) {
- ticket_type[currentIndex2] = "local";
- } else {
- ticket_type[currentIndex2] = "broad";
- }
- System.out.print(" > Enter Ticket Number: ");
- ticket_numbers[currentIndex2] = input.next();
- System.out.print(" > Enter emlpyee ID: ");
- employees_id[currentIndex2] = input.nextInt();
- System.out.print(" > Enter employee name: ");
- employees_names[currentIndex2] = input.next();
- employees_names[currentIndex2] += " " + input.next();
- System.out.print(" > Enter ticket price: ");
- price[currentIndex2] = input.nextInt();
- System.out.println(" ");
- System.out.println("> Ticket " + ticket_numbers[currentIndex2] + " for employee " + employees_names[currentIndex2] + " has been issued and added to the system.");
- break;
- case 3:
- if (employeeCount == 0) {
- System.out.println("> *** Cannot remove. There are no tickets currently added in the system.");
- } else {
- System.out.println("");
- System.out.print(" > Enter ticket number: ");
- String currentTicket = input.next();
- int position = Search(ticket_numbers, currentTicket, employeeCount);
- if (position == -1) {
- System.out.println("> ERROR: cannot remove ticek (NO #" + currentTicket + ")\n"
- + "> Ticket was not found in the system.");
- } else {
- removeTicket(ticket_numbers,employees_id,employees_names,ticket_type,price,position,employeeCount);
- System.out.println("> The tickst record has been deleted successfully.");
- }
- }
- break;
- case 4:
- if (employeeCount == 0) {
- System.out.println("> *** Cannot print details. There are no tickets currently added in the system.");
- } else {
- System.out.println("");
- System.out.print(" > Enter employee id: ");
- int id = input.nextInt();
- int employeeId = search(employees_id, id, employeeCount);
- if (employeeId == -1) {
- System.out.println("> ERROR: cannot display ticket details for the employee (#" + id + ")");
- System.out.println("> Ticket for this employee was not found in the system.");
- } else {
- System.out.println("");
- System.out.println(">>The ticket details is: ");
- System.out.println(" Ticket No: " + ticket_numbers[employeeId]);
- System.out.println(" Name: " + employees_names[employeeId]);
- System.out.println(" Ticket Type: " + ticket_type[employeeId]);
- System.out.println(" Price: " + price[employeeId]);
- System.out.println("");
- }
- }
- break;
- case 5:
- if (employeeCount == 0) {
- System.out.println("> *** Cannot print Tickets Statistics. There are no tickets currently added in the system.");
- } else {
- }
- break;
- case 0:
- System.out.println("");
- System.out.println("> Thank you for using the Ticket Issuing Management System!");
- System.out.println("> Goodbye.");
- System.exit(0);
- }
- }
- }
- public static void displayMainMenu() {
- System.out.println("");
- System.out.println("-----------------------------------------------------------\n"
- + "------- Ticket Issuing Management System ------\n"
- + "------- *MAIN MENU* ------\n"
- + "-----------------------------------------------------------\n"
- + "| 1: Enter 1 for Issuing a local Ticket |\n"
- + "| 2: Enter 2 for Issuing a broad Ticket |\n"
- + "| 3: Enter 3 for Removing a Ticket |\n"
- + "| 4: Enter 4 for Printing Ticket for an Employee |\n"
- + "| 5: Enter 5 for Printing the Tickets Details |\n"
- + "| 0: Enter 0 for Exiting the Program |\n"
- + "-----------------------------------------------------------");
- System.out.print("> Please enter your choice: ");
- } // Done
- public static byte inputAndCheck() {
- Scanner input = new Scanner(System.in);
- byte choice = input.nextByte();
- if (choice > 5) {
- System.out.println("");
- System.out.println("“>Invalid selection! Please\n"
- + "try again.");
- }
- return choice;
- } //Done
- public static int search(int[] emId, int employeeid, int employeeCount) {
- int results = -1;
- for (int i = 0; i < employeeCount; i++) {
- if (emId[i] == employeeid) {
- results = i;
- break;
- }
- }
- return results;
- } // Done
- public static int Search(String[] tickets, String ticket, int employeeCount) {
- int results = -1;
- for (int i = 0; i < employeeCount; i++) {
- if (tickets[i].equalsIgnoreCase(ticket)) {
- results = i;
- }
- }
- return results;
- } // Done
- public static void removeTicket(String[] tickets, int[] emId, String[] employees_names,
- String[] tickettype, double[] price, int position,int employeeCount) {
- }
- public static double displayTicketsInformation(String[] tickets, int[] emId, String[] employees_names,
- String[] tickettype, double[] price, String ticket_Type, int employeeCount) {
- System.out.println("Ticket Details based on Ticket Type");
- System.out.println("===================================================================================");
- System.out.println("");
- System.out.println("===================================================================================");
- System.out.println("");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement