Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1) Write a java program with the following steps: 1- Create a java class file Person which has the following properties: > Person -name:String -gender:String

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Q1) Write a java program with the following steps: 1- Create a java class file Person which has the following properties: > Person -name:String -gender:String -SSN:long +constructors (you should include all the needed constructors) +getters and setters(you should include the setters and getters needed for data members) +override method toString():String (represent the person with all his/her information) +override method equals(Person p):boolean (it will check the equality of any two persons according to their name and ssn) Note: gender data member takes Male or Female value. 2- Create another java class file Student inherited from Person class which has the following properties: Student -major:String -yearofReg:int -ID:long +constructors (you should include all the needed constructors) +getters and setters(you should include the setters and getters needed for data members) +override method toString():String (represent the Student with all his/her information) +override method equals(Student s):boolean (it will check the equality of any two students according to their id) Note: major data member takes Computer Science, Computer Engineering, Software Engineering, Computer Information System, or Network Engineering and Security value only, and yearofReg represents the year of registration in the major. 3- Create a final java class file Employee inherited from Person class which has the following properties: Employee -type:String -salary:double +constructors (you should include all the needed constructors) +getters and setters(you should include the setters and getters needed for data members) +override method toString():String (represent the employee with all his/her information) +override method equals(Employee e):boolean (it will check the equality of any two em poyees according to their ssn) Note: type data member takes Full Time, Part Time, Casual, or Outworkers. 4- Create java main class file Test and do the following: A) Declare an array all Persons of type person with size 5. B) Print the following menu to give the user optionality: Choose 1 to insert a new student. Choose 2 to insert a new employee. Choose 3 to retrieve the maximum salary. Choose 4 to retrieve all software engineering students. Choose O to exit. C) when the user chooses the first choice, you should check the allPersons array if it is full then give him/her a "sorry, you reach the maximum length" message else prompt from the user to enter full information for the new student (name, SSN, gender, major, yearofreg, and id) then print all the persons with the new one. D) when the user chooses the second one, you should check the allPersons array if it is full then give him/her a "sorry, you reach the maximum length" message else prompt from the user to enter full information for the new employee (name, SSN, gender, type, and salary) then print all the persons with the new one. E) when the user chooses the third choice, you should retrieve the information of all employees with a maximum salary. F) when the user chooses the last choice, you should retrieve the information of all the students with a software engineering major. Sample Run: Choose 1 to insert a new student. Choose 2 to insert a new employee. Choose 3 to retrieve the maximum salary. Choose 4 to retrieve all software engineering students. Choose O to exit. Please enter your choice: 1 Please enter the name: Ahmad ali Please enter the SSN: 123 Please enter the gender: Male Please enter the major: Software engineering Please enter the id: 93210 Please enter the year of registration in the university: 2021 The allPersons array contains: Ahmad Ali 123 Male Software engineering 93210 2021 Choose 1 to insert a new student. Choose 2 to insert a new employee. Choose 3 to retrieve the maximum salary. Choose 4 to retrieve all software engineering students. Choose O to exit. Please enter your choice: 2 Please enter the name: Muna na'amneh Please enter the SSN: 456 Please enter the gender: Female Please enter the type of employee: Full Time Please enter the salary: 250 The allPersons array contains: Ahmad Ali 123 Male Software engineering 93210 2021 Muna Na'amneh 456 Female Full-time 250 Choose 1 to insert a new student. Choose 2 to insert a new employee. Choose 3 to retrieve the maximum salary. Choose 4 to retrieve all software engineering students. Choose O to exit. Please enter your choice: 2 Please enter the name: Waleed Samarah Please enter the SSN: 789 Please enter the gender: Male Please enter the type of employee: Part Time Please enter the salary: 500 The allPersons array contains: Ahmad Ali 123 Male Software engineering 93210 2021 Muna Na'amneh 456 Female Full-time 250 Waleed Samarah 789 Male Part-time 500 Choose 1 to insert a new student. Choose 2 to insert a new employee. Choose 3 to retrieve the maximum salary. Choose 4 to retrieve all software engineering students. Choose O to exit. Please enter your choice: 3 The employee/s with the maximum salary is/are: Waleed Samarah 789 Male Part-time 500 Choose 1 to insert a new student. Choose 2 to insert a new employee. Choose 3 to retrieve the maximum salary. Choose 4 to retrieve all software engineering students. Choose O to exit. Please enter your choice: 4 The student/s with software engineering major is/are: Ahmad Ali 123 Male Software engineerin Q2) write a java program with the following steps: 1- Create a java class file Book which has the following properties: Book -title:String -price:double -category: String -authorName: Author +constructors (you should include all the needed constructors) +getters and setters(you should include the setters and getters needed for data members) +override method to String():String (represent the book with all its information) +override method equals(Book b):boolean (it will check the equality of any two books according to their title) Note: Category data member takes historical, Health, or academic value. 2- Create another java class file Author which has the following properties: Author -name:String -gender:String +constructors (you should include all the needed constructors) +getters and setters(you should include the setters and getters needed for data members) +override method to String(): String (represent the author with all his/her information) +override method equals(Author a):boolean (it will check the equality of any two authors according to their name and gender. Note: gender data member takes Male or Female value. 3- Create java main class file Test1 and do the following: A) Declare an array allBooks of type book with size 3. B) Print the following menu to give the user optionality: Choose 1 to insert a new book. Choose 2 to retrieve historical books. Choose 3 to check the equality of first and last books in the array. Choose 0 to exit. C) When the user chooses the first choice, you should check the allBooks array if it is full then give him/her a "sorry, you reach the maximum length" message else prompt from the user to enter full information for the new book (title, price, type, and the info of author (name and gender)) then print all the books with the new one. D) When the user chooses the second choice, you should retrieve the information of all the books with history type. E) When the user chooses the last choice, you should check the equality of the first book with the last book in the array by using the override method equals (in Book class). Sample Run: Choose 1 to insert a new book. Choose 2 to retrieve history books. Choose 3 to check the equality of first and last books in the array. Choose O to exit. Please enter your choice: 1 Please enter the title: Introduction to java programming. Please enter the price: 35 Please enter the type: Academic Please enter the author name: Dietel Liang Please enter his/her gender: Male The allBooks array contains: Introduction to java programming 35 his author Dietel Liang Male Choose 1 to insert a new book. Choose 2 to retrieve history books. Choose 3 to check the equality of first and last books in the array. Choose 0 to exit. Please enter your choice: 1 Please enter the title: History of the Caliphs Please enter the price: 57 Please enter the type: Historical Please enter the author name: Jalaluddin Al-Suyuti Please enter his/her gender: Male The allBooks array contains: Introduction to java programming 35 Academic his author Dietel Liang Male History of the Caliphs 57 Historical his author Jalaluddin Al-Suyuti Male Choose 1 to insert a new book. Choose 2 to retrieve history books. Choose 3 to check the equality of first and last books in the array. Choose 0 to exit. Please enter your choice: 2 The Historical book/s is/are: History of the Caliphs 57 Historical his author Jalaluddin Al-Suyuti Male Choose 1 to insert a new book. Choose 2 to retrieve history books. Choose 3 to check the equality of first and last books in the array. Choose 0 to exit. Please enter your choice: 3 Introduction to java programming not equal to History of the Caliphs. Good Luck

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions