In: Computer Science
Programming Language = JAVA
I wanna make menu -driven using these items.
1. one
2. two
3. three
4. four
5. exit
This program will read a txt data and will display them in console.
text.txt
98765432,C,John,Smith,23 Church Ave,Central,2123,8,Valid
98765431,C,Joe,Smith,55 Church Street,Genzi,2323,0,Valid
98765430,C,Bob,Smith,23 Gong Road,Warambull,2443,0,Valid
98765429,C,Mike,Smith,42 Mike Street,Waterloo,2222,0,Valid
98765428,C,Juan,Smith,522 Banana steet,Bank,2423,2,Valid
98765427,C,Mike,Jones,232 Milemium
lane,Sumrise,2753,13,Suspended
98765426,C,David,Smith,551 Russian Mountain
ave,Kogara,2121,0,Valid
98765425,C,Sarah,Smith,123 Straight
Street,Cronulla,2232,3,Valid
98765424,C,James,Smith,23 lane,Coroloa,2345,7,Valid
98765423,C,Mike,White,4 Loman Lane,Orange,2665,14,Suspended
98765422,C,Brendon,Fei,55 bal bay,sate,2757,0,Valid
98765421,C,Jian,Zhang,62 london Street,mango,2553,0,Valid
98765420,C,Choi,Saraha,11 hamberguer
Street,kefece,2753,0,Valid
98765432,C,Godam,City,32 Kent Street,Maccus,2876,0,Valid
when user press 1, this program will display a report about this txt file.
a report will include number(98765420), family name, first name, suburb, point(0,3,2,,,), status(valid).
please display well-organized format, and also please provide special option which displays this report in the decending order of point(0,3,2).
/************************Person.java*******************/
/**
* The Class Person.
*/
public class Person implements Comparable<Person> {
/** The number. */
private int number;
/** The family name. */
private String familyName;
/** The first name. */
private String firstName;
/** The subrub. */
private String subrub;
/** The point. */
private int point;
/** The status. */
private String status;
/**
* Instantiates a new person.
*
* @param number the number
* @param familyName the family name
* @param firstName the first name
* @param subrub the subrub
* @param point the point
* @param status the status
*/
public Person(int number, String familyName, String
firstName, String subrub, int point, String status) {
super();
this.number = number;
this.familyName = familyName;
this.firstName = firstName;
this.subrub = subrub;
this.point = point;
this.status = status;
}
/**
* Gets the number.
*
* @return the number
*/
public int getNumber() {
return number;
}
/**
* Sets the number.
*
* @param number the new number
*/
public void setNumber(int number) {
this.number = number;
}
/**
* Gets the family name.
*
* @return the family name
*/
public String getFamilyName() {
return familyName;
}
/**
* Sets the family name.
*
* @param familyName the new family name
*/
public void setFamilyName(String familyName) {
this.familyName = familyName;
}
/**
* Gets the first name.
*
* @return the first name
*/
public String getFirstName() {
return firstName;
}
/**
* Sets the first name.
*
* @param firstName the new first name
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* Gets the subrub.
*
* @return the subrub
*/
public String getSubrub() {
return subrub;
}
/**
* Sets the subrub.
*
* @param subrub the new subrub
*/
public void setSubrub(String subrub) {
this.subrub = subrub;
}
/**
* Gets the point.
*
* @return the point
*/
public int getPoint() {
return point;
}
/**
* Sets the point.
*
* @param point the new point
*/
public void setPoint(int point) {
this.point = point;
}
/**
* Gets the status.
*
* @return the status
*/
public String getStatus() {
return status;
}
/**
* Sets the status.
*
* @param status the new status
*/
public void setStatus(String status) {
this.status = status;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Person \nNumber=" + number
+ "\nFamily Name=" + familyName + "\nFirst Name=" + firstName +
"\nSubrub="
+ subrub + "\nPoint=" + point + "\nStatus=" +
status;
}
/*
* (non-Javadoc)
*
* @see
java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(Person arg0) {
if (this.point < arg0.point)
{
return
1;
} else if (this.point >
arg0.point) {
return
-1;
} else {
return 0;
}
}
}
/***********************************Assignment.java************************/
1. Display All
2. Sort By Point
3. three
4. four
5. exit
Select one option: 1
Person
Number=98765432
Family Name=JohnSmith
First Name=John
Subrub=Central
Point=2123
Status=Valid
Person
Number=98765431
Family Name=JoeSmith
First Name=Joe
Subrub=Genzi
Point=2323
Status=Valid
Person
Number=98765430
Family Name=BobSmith
First Name=Bob
Subrub=Warambull
Point=2443
Status=Valid
Person
Number=98765429
Family Name=MikeSmith
First Name=Mike
Subrub=Waterloo
Point=2222
Status=Valid
Person
Number=98765428
Family Name=JuanSmith
First Name=Juan
Subrub=Bank
Point=2423
Status=Valid
Person
Number=98765427
Family Name=MikeJones
First Name=Mike
Subrub=Sumrise
Point=2753
Status=Suspended
Person
Number=98765426
Family Name=DavidSmith
First Name=David
Subrub=Kogara
Point=2121
Status=Valid
Person
Number=98765425
Family Name=SarahSmith
First Name=Sarah
Subrub=Cronulla
Point=2232
Status=Valid
Person
Number=98765424
Family Name=JamesSmith
First Name=James
Subrub=Coroloa
Point=2345
Status=Valid
Person
Number=98765423
Family Name=MikeWhite
First Name=Mike
Subrub=Orange
Point=2665
Status=Suspended
Person
Number=98765422
Family Name=BrendonFei
First Name=Brendon
Subrub=sate
Point=2757
Status=Valid
Person
Number=98765421
Family Name=JianZhang
First Name=Jian
Subrub=mango
Point=2553
Status=Valid
Person
Number=98765420
Family Name=ChoiSaraha
First Name=Choi
Subrub=kefece
Point=2753
Status=Valid
Person
Number=98765432
Family Name=GodamCity
First Name=Godam
Subrub=Maccus
Point=2876
Status=Valid
1. Display All
2. Sort By Point
3. three
4. four
5. exit
Select one option: 2
Person
Number=98765432
Family Name=GodamCity
First Name=Godam
Subrub=Maccus
Point=2876
Status=Valid
Person
Number=98765422
Family Name=BrendonFei
First Name=Brendon
Subrub=sate
Point=2757
Status=Valid
Person
Number=98765427
Family Name=MikeJones
First Name=Mike
Subrub=Sumrise
Point=2753
Status=Suspended
Person
Number=98765420
Family Name=ChoiSaraha
First Name=Choi
Subrub=kefece
Point=2753
Status=Valid
Person
Number=98765423
Family Name=MikeWhite
First Name=Mike
Subrub=Orange
Point=2665
Status=Suspended
Person
Number=98765421
Family Name=JianZhang
First Name=Jian
Subrub=mango
Point=2553
Status=Valid
Person
Number=98765430
Family Name=BobSmith
First Name=Bob
Subrub=Warambull
Point=2443
Status=Valid
Person
Number=98765428
Family Name=JuanSmith
First Name=Juan
Subrub=Bank
Point=2423
Status=Valid
Person
Number=98765424
Family Name=JamesSmith
First Name=James
Subrub=Coroloa
Point=2345
Status=Valid
Person
Number=98765431
Family Name=JoeSmith
First Name=Joe
Subrub=Genzi
Point=2323
Status=Valid
Person
Number=98765425
Family Name=SarahSmith
First Name=Sarah
Subrub=Cronulla
Point=2232
Status=Valid
Person
Number=98765429
Family Name=MikeSmith
First Name=Mike
Subrub=Waterloo
Point=2222
Status=Valid
Person
Number=98765432
Family Name=JohnSmith
First Name=John
Subrub=Central
Point=2123
Status=Valid
Person
Number=98765426
Family Name=DavidSmith
First Name=David
Subrub=Kogara
Point=2121
Status=Valid
1. Display All
2. Sort By Point
3. three
4. four
5. exit
Select one option: 5
Please let me know if you have any doubt or modify the answer, Thanks :)