Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.io.File; import java.io.IOException; import java.io. PrintWriter; import java.nio.charset.StandardCharsets; import java.nio.file. StandardOpenOption; import java.util.ArrayList; import java.util.Scanner; import java.nio.file.Files; public class PersonGenerator { 4 usages

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

import java.io.File; import java.io.IOException; import java.io. PrintWriter; import java.nio.charset.StandardCharsets; import java.nio.file. StandardOpenOption; import java.util.ArrayList; import java.util.Scanner; import java.nio.file.Files; public class PersonGenerator { 4 usages private static int id = 00001; 3 usages private static int ctr = 0; public static void main(String[] args) throws IOException { ArrayList list = new ArrayList (); Scanner in = new Scanner(System.in); SafeInput safeInput = new SafeInput(); while(true) { if(ctr == 0) { String list_string = ""; list_string += String.format("%05d", id) + list_string += safeInput.getNonZero LenString(in, prompt: "Enter First Name") + list_string += safeInput.getNonZeroLen String (in, prompt: "Enter Last Name") + list_string += safeInput.getNonZeroLen String (in, prompt: "Enter Title") + list_string += String.valueOf(safeInput.getRanged Int (in, prompt: "Enter DoB list.add(list_string); id++; ctr++; }else if (ctr == 1) { boolean res = safeInput.getYNConfirm (in, prompt: "Are there more records?"); if(res) { String list_string = . list_string += String.format("%05d", id) + ' ' ' low: 1000, high: 9999)); list_string += safeInput.getNonZeroLenstring (in, prompt: "Enter First Name") + list_string += safeInput.getNonZeroLenString(in, prompt: "Enter Last Name") + list_string += safeInput.getNonZeroLen String (in, prompt: "Enter Title") + ", list_string += String.valueOf(safeInput.getRangedInt(in, prompt: "Enter Date of Birth ", low: 1000, high: 9999)); list.add(list_string); } } } id++; } else if (!res) { System.out.println(" "); for(int i = 0; i < list.size(); i++) { System.out.printf(" ",list.get(i)); PrintWriter out = new PrintWriter(fileName: "PersonTestData"); out.println(list); out.close(); //Files.write(Person TestData.toPath(), content.getBytes(StandardCharsets.UTF-8), StandardOpenOption.CREATE) } break; } [00001, Bilbo, Baggins, Esq., 1060] [00002, Frodo, Baggins, Esq., 1120] SonGenerator.java Person TestData PersonReader.java [00001, Bilbo, Baggins, Esq., 1060, 00002, Frodo, Baggins, Esq., 1120] wwwwwww

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Usability

Authors: Jakob Nielsen, Raluca Budiu

1st Edition

0133122131, 9780133122138

More Books

Students also viewed these Programming questions

Question

In how many ways can the top 2 horses nish in a 10-horse race?

Answered: 1 week ago