Question: public class Person { String fName; String lName; int ID; static int nextID = 101; Person() { fName = unk; lName = unk; ID =

 public class Person { String fName; String lName; int ID; static

int nextID = 101; Person() { fName = "unk"; lName = "unk";

public class Person { String fName; String lName; int ID; static int nextID = 101; Person() { fName = "unk"; lName = "unk"; ID = nextID++; } Person(String fName, String lName) { this.fName = fName; this.lName = lName; ID = nextID++; } public void setFName(String fName) { this.fName = fName; } public String getFName() { return fName; } public void setLName(String lName) { this.lName = lName; } public String getLName() { return lName; } public int getID() { return ID; } } 

 import java.text.*; // to use Decimal Format public class TwoD_ArrayDriver { public static void main(String[] args) { DecimalFormat myFormat; // to get 2 decimals every time myFormat = new DecimalFormat("#.00"); Person p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21; p1 = new Person("Abby", "Arthur"); p2 = new Person("Bubba","Brown"); p3 = new Person("Chuckie", "Cheese"); p4 = new Person("Don", "Drysdale"); p5 = new Person("Ernie","Eastwood"); p6 = new Person("Flo", "Fauntroy"); p7 = new Person("Gabby", "Giffords"); p8 = new Person("Hank","Hoover"); p9 = new Person("Indy", "Imhauf"); p10 = new Person("Jim","Jones"); p11 = new Person("Ken", "Koopman"); p12 = new Person("Larry", "Lancelot"); p13 = new Person("Michael", "Moore" ); p14 = new Person("Nina","Nonesuch"); p15 = new Person("Oscar","OToole"); p16 = new Person("Pat","Pompous"); p17 = new Person("Quincy","Quinton"); p18 = new Person("Ralph","Rancid"); p19 = new Person("Steven","Simpson"); p20 = new Person("Tim","Tinker"); p21 = new Person("Uncle","Usher"); Person[] allPersons = {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21}; Person[] mondayAppts = {p1, p2, p3, p4, p5}; Person[] tuesdayAppts = {p6, p7, p8}; Person[] wednesdayAppts = {p9, p10, p11, p12}; Person[] thursdayAppts = {p13, p14, p15, p16, p17}; Person[] fridayAppts = {p18, p19, p20, p21}; //Task #1 Print the id, first name, and last name of Person #7, using tuesdayAppts int intToPrint = 0; String fNameToPrint = "unknown"; String lNameToPrint = "unknown"; System.out.println("Person #7 "+intToPrint+" "+fNameToPrint+" "+lNameToPrint); //Task #2 Create a 2D array out of the 1D arrays //Task #3 Print the id of Person #8, using weeklyAppts intToPrint = 0; fNameToPrint = "unknown"; lNameToPrint = "unknown"; System.out.println("Person #8's ID "+intToPrint+" "+fNameToPrint+" "+lNameToPrint); //Task #4 Print the length of thursdayAppts using weeklyAppts intToPrint = 0; System.out.println("Length of Thursday's appts "+intToPrint); //Task #5 Print all using weeklyAppts int ctr = 1; for (int i=0; i  In this lab, you are introduced to two-dimensional arrays. You are provided with the class Person, and five one-dimensional arrays of Person, and required to combine them into a two-dimensional array The data represents a list of appointments for five days of the week. Each array contains the people scheduled for one day's appointment. Follow the directions exactly, and in order Task #1 Find an element of a 1D array l. Using the existing ID array called tuesdayAppts, find Person p7 2. Set intToPrint as the ID of Person p7, using tuesdayAppts and the accessor found in the file Person java. Do not access p7 directly 3. Set fNameToPrint and lNameToPrint of Person p7 4. Run the program to see the result. Task #2 Create a 2D Array l. Declare a2D array called weeklyAppts 2. Instantiate weeklyAppts using the five daily appointment ID arrays. Task #3 Find an element of a 2D array l. Using the 2D array called weeklyAppts, find Person #8 (p8). 2. Set intToPrint as the ID of Person p8, using weeklyAppts. 3. Set fName ToPrint and lNameToPrint of Person p8. 4. Run the program to see the result. Task #4 Find the length of a 1D array in a 2D array l. Using weeklyAppts, set int ToPrint to the length of thursdayAppts 2. Run the program to see the result

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!