Listing.java
import java.util.Scanner;
public class Listing {
//Declaring instance variables
private String name;
private int age;
//Default constructor
public Listing() {
name=\" \";
age=0;
}
//parameterized Constructor
public Listing(String name, int age) {
super();
this.name = name;
this.age = age;
}
//Getters and setters
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;
}
//This input() method will take the inputs entered by the user.
public void input()
{
//Scanner Object is used to get the data entered by the user
Scanner sc=new Scanner(System.in);
//Getting the user name
System.out.print(\"Enter Name :\");
setName(sc.nextLine());
//Getting the Age
System.out.print(\"Enter Age :\");
setAge(sc.nextInt());
}
//This toString() method will displays the constents of the user.
@Override
public String toString() {
System.out.println(\"Name :\"+getName());
System.out.println(\"Name :\"+getAge());
return \"\";
}
}
_____________________________________________________________
Driver.java
public class Driver {
public static void main(String[] args) {
//Create an array of 3 Listing Objects
Listing listing[]=new Listing[3];
//Creating Listing Objects and populating into an Array
for(int i=0;i<3;i++)
{
listing[i]=new Listing();
System.out.println(\"Listing Object \"+(i+1)+\":\");
//Calling the input method which capture the data entered by the user
listing[i].input();
}
//Displaying the Listing objects in the Normal Order
System.out.println(\"Displaying the Listing Objects in the Normal Order ::\");
for(int i=0;i<3;i++)
{
System.out.println(\"Listing Object \"+(i+1)+\":\");
listing[i].toString();
System.out.println(\"_____________________\");
}
//Displaying the Listing objects in the Reverse Order
System.out.println(\"Displaying the Listing Objects in the Reverse Order ::\");
for(int i=2;i>=0;i--)
{
System.out.println(\"Listing Object \"+(i+1)+\":\");
listing[i].toString();
System.out.println(\"_____________________\");
}
}
}
_______________________________________________________
Output:
Listing Object 1:
Enter Name :Kane Williams
Enter Age :27
Listing Object 2:
Enter Name :John Mills
Enter Age :23
Listing Object 3:
Enter Name :Tim Rochey
Enter Age :22
Displaying the Listing Objects in the Normal Order ::
Listing Object 1:
Name :Kane Williams
Name :27
_____________________
Listing Object 2:
Name :John Mills
Name :23
_____________________
Listing Object 3:
Name :Tim Rochey
Name :22
_____________________
Displaying the Listing Objects in the Reverse Order ::
Listing Object 3:
Name :Tim Rochey
Name :22
_____________________
Listing Object 2:
Name :John Mills
Name :23
_____________________
Listing Object 1:
Name :Kane Williams
Name :27
_____________________
_____________________________________________Thank You
Solution
Listing.java
import java.util.Scanner;
public class Listing {
//Declaring instance variables
private String n.
Mattingly "AI & Prompt Design: Named Entity Recognition"
Listing.javaimport java.util.Scanner;public class Listing { .pdf
1. Listing.java
import java.util.Scanner;
public class Listing {
//Declaring instance variables
private String name;
private int age;
//Default constructor
public Listing() {
name=" ";
age=0;
}
//parameterized Constructor
public Listing(String name, int age) {
super();
this.name = name;
this.age = age;
}
//Getters and setters
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;
}
//This input() method will take the inputs entered by the user.
public void input()
2. {
//Scanner Object is used to get the data entered by the user
Scanner sc=new Scanner(System.in);
//Getting the user name
System.out.print("Enter Name :");
setName(sc.nextLine());
//Getting the Age
System.out.print("Enter Age :");
setAge(sc.nextInt());
}
//This toString() method will displays the constents of the user.
@Override
public String toString() {
System.out.println("Name :"+getName());
System.out.println("Name :"+getAge());
return "";
}
}
_____________________________________________________________
Driver.java
public class Driver {
public static void main(String[] args) {
//Create an array of 3 Listing Objects
Listing listing[]=new Listing[3];
//Creating Listing Objects and populating into an Array
for(int i=0;i<3;i++)
{
listing[i]=new Listing();
System.out.println("Listing Object "+(i+1)+":");
//Calling the input method which capture the data entered by the user
3. listing[i].input();
}
//Displaying the Listing objects in the Normal Order
System.out.println("Displaying the Listing Objects in the Normal Order ::");
for(int i=0;i<3;i++)
{
System.out.println("Listing Object "+(i+1)+":");
listing[i].toString();
System.out.println("_____________________");
}
//Displaying the Listing objects in the Reverse Order
System.out.println("Displaying the Listing Objects in the Reverse Order ::");
for(int i=2;i>=0;i--)
{
System.out.println("Listing Object "+(i+1)+":");
listing[i].toString();
System.out.println("_____________________");
}
}
}
_______________________________________________________
Output:
Listing Object 1:
Enter Name :Kane Williams
Enter Age :27
Listing Object 2:
Enter Name :John Mills
Enter Age :23
Listing Object 3:
Enter Name :Tim Rochey
Enter Age :22
Displaying the Listing Objects in the Normal Order ::
Listing Object 1:
4. Name :Kane Williams
Name :27
_____________________
Listing Object 2:
Name :John Mills
Name :23
_____________________
Listing Object 3:
Name :Tim Rochey
Name :22
_____________________
Displaying the Listing Objects in the Reverse Order ::
Listing Object 3:
Name :Tim Rochey
Name :22
_____________________
Listing Object 2:
Name :John Mills
Name :23
_____________________
Listing Object 1:
Name :Kane Williams
Name :27
_____________________
_____________________________________________Thank You
Solution
Listing.java
import java.util.Scanner;
public class Listing {
//Declaring instance variables
private String name;
private int age;
//Default constructor
5. public Listing() {
name=" ";
age=0;
}
//parameterized Constructor
public Listing(String name, int age) {
super();
this.name = name;
this.age = age;
}
//Getters and setters
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;
}
//This input() method will take the inputs entered by the user.
public void input()
{
//Scanner Object is used to get the data entered by the user
Scanner sc=new Scanner(System.in);
//Getting the user name
System.out.print("Enter Name :");
setName(sc.nextLine());
//Getting the Age
6. System.out.print("Enter Age :");
setAge(sc.nextInt());
}
//This toString() method will displays the constents of the user.
@Override
public String toString() {
System.out.println("Name :"+getName());
System.out.println("Name :"+getAge());
return "";
}
}
_____________________________________________________________
Driver.java
public class Driver {
public static void main(String[] args) {
//Create an array of 3 Listing Objects
Listing listing[]=new Listing[3];
//Creating Listing Objects and populating into an Array
for(int i=0;i<3;i++)
{
listing[i]=new Listing();
System.out.println("Listing Object "+(i+1)+":");
//Calling the input method which capture the data entered by the user
listing[i].input();
}
//Displaying the Listing objects in the Normal Order
System.out.println("Displaying the Listing Objects in the Normal Order ::");
for(int i=0;i<3;i++)
{
System.out.println("Listing Object "+(i+1)+":");
listing[i].toString();
7. System.out.println("_____________________");
}
//Displaying the Listing objects in the Reverse Order
System.out.println("Displaying the Listing Objects in the Reverse Order ::");
for(int i=2;i>=0;i--)
{
System.out.println("Listing Object "+(i+1)+":");
listing[i].toString();
System.out.println("_____________________");
}
}
}
_______________________________________________________
Output:
Listing Object 1:
Enter Name :Kane Williams
Enter Age :27
Listing Object 2:
Enter Name :John Mills
Enter Age :23
Listing Object 3:
Enter Name :Tim Rochey
Enter Age :22
Displaying the Listing Objects in the Normal Order ::
Listing Object 1:
Name :Kane Williams
Name :27
_____________________
Listing Object 2:
Name :John Mills
Name :23
_____________________
Listing Object 3:
Name :Tim Rochey
8. Name :22
_____________________
Displaying the Listing Objects in the Reverse Order ::
Listing Object 3:
Name :Tim Rochey
Name :22
_____________________
Listing Object 2:
Name :John Mills
Name :23
_____________________
Listing Object 1:
Name :Kane Williams
Name :27
_____________________
_____________________________________________Thank You