Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

demonstrates each method in ule below and write a driver program (progressively

ID: 3744927 • Letter: D

Question

demonstrates each method in ule below and write a driver program (progressively developed) to test the class (verify that all the methods function properly). The default (n parameter constructor) should initialize the String data member name to.a data member to zero. The input method should allow the user to input the values of an 41. Write the class whose diagram is shown and numeri object's data members. Listing String name - int age + Listing() + Listing (String, int) + String toString() + void input() + void setName (String) + void setAge (String) + String getName () + int getAge ()

Explanation / Answer

import java.util.Scanner; public class Listing { private String name; private int age; public Listing() { name = " "; age = 0; } public Listing(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public String toString() { return "name='" + name + ''' + ", age=" + age; } public void input() { Scanner in = new Scanner(System.in); System.out.print("Enter name: "); name = in.nextLine(); System.out.print("Enter age: "); age = Integer.parseInt(in.nextLine()); } } public class ListingMain { public static void main(String[] args) { Listing[] listings = new Listing[3]; for(int i = 0; i = 0; --i) { System.out.println(listings[i]); } } }