Given the sample.txt and reference class, come up with the main class of the code so that the program will generate the sample run provided (see attached image):   Sample.txt: Bieber,Justine,W,American,16 Green,Charlie,B,British,13 Concepcion,Sam,V,Filipino,17 Pempingco,Charice,A,Filipino,18 Gaga,Lady,D,American,20   Reference class: public class Person implements Comparable { private String name;   private String nationality; private int age; public Person(String n, String c, int a) { name = n; nationality = c; age = a; } public int getAge() { return age; } public String toString() { return (name + "," + nationality + "," + age); } public int compareTo(Person another) { if (age == another.getAge()) return 0; else if (age < another.getAge()) return -1; else return 1; } // end of compareTo } // end of Person   Please complete the code below:    public class Activity{ public static void main(String[]args) {   try { activity=new Activity(); // 1. Invoke the run method ____________________________; } catch(FileNotFoundException e1) { System.out.println(e1.getMessage()); } catch(NumberFormatException e2) { //2. Print the message attribute of the exception __________________________; } catch(Exception e3) { e3.printStackTrace(); } finally { System.out.println("End of Process"); } System.exit(0); } // end of main public void run() throws _____________________________ { // 3. TO DO } } // end of class

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Given the sample.txt and reference class, come up with the main class of the code so that the program will generate the sample run provided (see attached image):

 

Sample.txt:

Bieber,Justine,W,American,16

Green,Charlie,B,British,13

Concepcion,Sam,V,Filipino,17

Pempingco,Charice,A,Filipino,18

Gaga,Lady,D,American,20

 

Reference class:

public class Person implements Comparable<Person> {

private String name;

 

private String nationality;

private int age;

public Person(String n, String c, int a) {

name = n;

nationality = c;

age = a;

}

public int getAge() {

return age;

}

public String toString() {

return (name + "," + nationality + "," + age);

}

public int compareTo(Person another) {

if (age == another.getAge())

return 0;

else if (age < another.getAge())

return -1;

else

return 1;

} // end of compareTo

} // end of Person

 

Please complete the code below: 

 

public class Activity{

public static void main(String[]args) {

 

try {

activity=new Activity();

// 1. Invoke the run method

____________________________;

} catch(FileNotFoundException e1) {

System.out.println(e1.getMessage());

} catch(NumberFormatException e2) {

//2. Print the message attribute of the exception

__________________________;

} catch(Exception e3) {

e3.printStackTrace();

} finally {

System.out.println("End of Process");

}

System.exit(0);

} // end of main

public void run() throws _____________________________ {

// 3. TO DO

}

} // end of class 

Sample run of the program:
Enter the name of the file from which data will be read: sample.txt
The following student data are produced where ages are in increasing order.
Charlie B Green, British, 13
Justine W Bieber , American, 16
Sam V Concepcion,Filipino,17
Charice A Pempengco,Filipino , 18
Lady D Gaga, American, 20
End of Process
Transcribed Image Text:Sample run of the program: Enter the name of the file from which data will be read: sample.txt The following student data are produced where ages are in increasing order. Charlie B Green, British, 13 Justine W Bieber , American, 16 Sam V Concepcion,Filipino,17 Charice A Pempengco,Filipino , 18 Lady D Gaga, American, 20 End of Process
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY