Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

In Lab 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) 1 +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: E! 2- Create another java class file Student inherited from Person class which has the following properties: 2 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) +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) 3 +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 allPersons 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 0 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: A Ahmad All 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 5 +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 book with all its information) override method equals(Book by 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 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 toString():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 6 Note: gender data member takes Male or Female value 3. Create lava main class file Test1 and do the following Al Declare an array Books of type book with size 3 B) Print the following menu to give the user optionality Choose 1 to insert a new book _05+Lab_06%20(1).pdf level 1 - Google Sh... ... ) beprogrammer-E-le... Note: gender data member takes Male or Female value. C) 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. 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). When 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 to exit Please enter your choice: 1 Please enter the title Introduction to java programming. Please enter the price: 35 Please enter the type: 7 Academic Please enter the author name Dietel Liang

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_2

Step: 3

blur-text-image_3

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions