splits int s1id if ID s1id SystemoutprintnID already

Splits int s1id if id s1id systemoutprintnid already

This preview shows page 2 - 5 out of 6 pages.

int s1_id = (Integer.parseInt(token[0]));if (ID == s1_id) {System.out.print("\nID already exists. Enter a new ID: ");p.setID(input.nextInt());p.checkID(p, p.getID());}}read.close();} catch (IOException e) {System.out.println(e);}}}public static void viewPassenger() {Scanner read = null;if (file.exists()) {try {read = new Scanner(file);while (read.hasNext()) {System.out.println(read.nextLine());
Background image
}read.close();} catch (IOException e) {System.out.println(e);}} else {System.out.println("File does not exist");System.out.println("Enter Data for Passengers first");}}public static void searchPassenger(int s_id) {Scanner read = null;if (file.exists()) {try {read = new Scanner(file);while (read.hasNext()) {String line = read.nextLine();String[] token = line.split("\\s+");int s1_id = (Integer.parseInt(token[0]));if (s1_id == s_id) {System.out.println("\nThe Data for Passenger having ID=" + s_id + " is: ");System.out.println(line + "\n");break;}}read.close();} catch (IOException e) {System.out.println(e);}} else {System.out.println("File does not exist");System.out.println("Enter Data for Passengers first\n");}}public static void searchPassenger(String s_name) {Scanner read = null;if (file.exists()) {try {read = new Scanner(file);while (read.hasNextLine()) {String line = read.nextLine();String[] token = line.split("\\s+");String s1_name = token[1];if ((s1_name.compareToIgnoreCase(s_name)) == 0) {System.out.println("\nThe Data for Passenger having name " + s_name + " is: ");System.out.println(line + "\n");}}read.close();} catch (IOException e) {System.out.println(e);}} else {System.out.println("File does not exist");System.out.println("Enter Data for Passengers first\n");}}public static void deletePassenger(int s_id) {Scanner read = null;
Background image
File temp = null;PrintWriter pw = null;if (file.exists()) {try {read = new Scanner(file);while (read.hasNext()) {String line = read.nextLine();String[] token = line.split("\\s+");int s1_id = (Integer.parseInt(token[0]));
Background image
Image of page 5

You've reached the end of your free preview.

Want to read all 6 pages?

  • Fall '17
  • Dr. Faisal Cheema
  • Passenger, CNIC, public class Passengers, public static File file

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture