Question: In Java please complete the TODO steps on the starter code *Person class* public class Person { public String firstName; public String lastName; public int

In Java please complete the TODO steps on the starter code

*Person class*

public class Person { public String firstName; public String lastName; public int idNum; public String city;

/** * Default constructor used to create empty attributes */ public Person() { firstName = ""; lastName = ""; idNum =0; city =""; }

/** * @param firstName * @param lastName * @param idNum * @param city */ public Person(String firstName, String lastName, int idNum, String city) { this.firstName = firstName; this.lastName = lastName; this.idNum = idNum; this.city = city; }

/* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return "Person [firstName=" + firstName + ", lastName=" + lastName + ", idNum=" + idNum + ", city=" + city + "]"; }

/** * @return the firstName */ public String getFirstName() { return firstName; }

/** * @param firstName the firstName to set */ public void setFirstName(String firstName) { this.firstName = firstName; }

/** * @return the lastName */ public String getLastName() { return lastName; }

/** * @param lastName the lastName to set */ public void setLastName(String lastName) { this.lastName = lastName; }

/** * @return the idNum */ public int getIdNum() { return idNum; }

/** * @param idNum the idNum to set */ public void setIdNum(int idNum) { this.idNum = idNum; }

/** * @return the city */ public String getCity() { return city; }

/** * @param city the city to set */ public void setCity(String city) { this.city = city; }

} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

*Starter Code*

import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Scanner;

public class ReadPeopleFromFile {

/** * @param args */ public static void main(String[] args) { ArrayList people = new ArrayList();

/* * TODO 1: * Create a scanner for reading from a file "peopleFile.txt" that * contains the information for persons */

/* TODO 2: * Use the scanner to read one person at a time. For each person, * create a Person object and add the object to the array list people. */

// print info to user System.out.println("The people from the file are:"); System.out.println(people);

/* * TODO 3: * Create a printer writer that will save the persons' info to "secondPeople.txt" */

/* TODO 4: * Use a for loop to write the persons' info to the file in the same format * as in input file "peopleFile.txt". */ /* * TODO 5: close the print writer */ }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!