do { String sName; String sMission; System.out.printf("%-11s%-20s%10s\n", "*****", "Add the station in behind", "*****"); System.out.print("Enter station name: "); sName = input.nextLine(); System.out.flush(); System.out.printf("%-15s\n%-15s\n%-15s\nYour Choice: ", "Select station mission", "1.MCQ", "2.True/False Quiz"); sMission = input.next(); System.out.flush(); if (sMission.equals("1")) { missionType = "|MCQ"; r.addFront(sName + missionType); } else if (sMission.equals("2")) { missionType = "|Quiz"; r.addFront(sName + missionType); } else { System.out.println("Invalid input must (1-2): "); Thread.sleep(2000); return; } //using overwrite to insert station File s = new File("Station.txt"); try { if (s.exists() == false) { s.createNewFile(); } PrintWriter fw = new PrintWriter(s); fw.append(r.toString());//using toString to write to text file fw.close(); System.out.println("Success to insert."); } catch (IOException e) { System.out.println("Could not create file"); } System.out.printf("Continue(Y/N)?"); selection = input.next(); } while (selection.equals("y") || selection.equals("Y"));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)