June 2017
Beginner
1296 pages
69h 23m
English
... (input.hasNext()) { // loop until end-of-file indicator 27 try { 28 // create new record 29 Account record = new Account(input.nextInt(), 30 input.next(), input.next(), input.nextDouble()); 31 32 // add to AccountList 33 accounts.getAccounts().add(record); 34 } 35 catch (NoSuchElementException elementException) { 36 System.err.println("Invalid input. Please try again."); 37 input.nextLine(); // discard input so user can try again 38 } 39 40 System.out.print("? "); 41 } 42 43 // write AccountList's XML to output 44 JAXB.marshal(accounts, output); 45 }46 catch (IOException ioException) { 47 System.err.println("Error opening file. Terminating."); 48 } 49 } 50 }
Enter account number, first name, last name and balance. Enter end-of-file indicator to ...