Write a java program that has: A class University that has: - Three private instance variables named firstName, lastName, and id - A constructor to initialize the three instance variables - A toString method to return: “Welcome,” + firstName +” “ + lastName + “Your ID is ” + id - Accessors A subclass Employee that has: - Five additional private instance variables named department, rate, bonus, hours, and salary - An appropriate constructor to use constructor of superclass in defining those of the subclass - A method named compteSalary ( ) to return salary - A method named computeBonus ( ) to return bonus - Accessors A subclass Staff that: - Overrides computeBonus ( ) such that if hours are greater than 40, there will be %10 bonus for each additional hour added to salary - Overrides compteSalary ( ) such that salary = (rate * hours) + bonus - Overrides toString method to add department and salary into the output A subclass Faculty that: - Overrides computeBonus ( ) such that if hours are greater than 40, there will be %25 bonus for each additional hour added to salary - Overrides compteSalary ( ) such that salary = (rate * hours) + bonus - Overrides toString method to add department and salary into the output A subclass Student that has: - Three additional private instance variables major, level, and grade - An appropriate constructor to use constructor of superclass in defining those of the subclass - One instance method computeGrade( ) to return the grade - Overrides toString method to add major and level into the output - Accessors A subclass Undergrade that has: - Three additional private instance variables named course1, course2, and course3 as double - An appropriate constructor to use constructor of superclass in defining those of the subclass - Overrides computeGade( ) such that grade = [(course1 + course2+ course3) / 300 ] * 100 - Overrides toString method to add grade into the output - Accessors A TestUniv class that has: - The main function to run your code. - Create objects to show two different outputs like: Output 1: Welcome, Ahmed Abdullah. Your ID is 123456 Your department is Computer Science and Engineering Your salary for this month is 10,000
Write a java program that has:
A class University that has:
- Three private instance variables named firstName, lastName, and id
- A constructor to initialize the three instance variables
- A toString method to return: “Welcome,” + firstName +” “ + lastName + “Your ID is ” + id
- Accessors
A subclass Employee that has:
- Five additional private instance variables named department, rate, bonus, hours, and salary
- An appropriate constructor to use constructor of superclass in defining those of the subclass
- A method named compteSalary ( ) to return salary
- A method named computeBonus ( ) to return bonus
- Accessors
A subclass Staff that:
- Overrides computeBonus ( ) such that if hours are greater than 40, there will be %10 bonus for each additional hour
added to salary
- Overrides compteSalary ( ) such that salary = (rate * hours) + bonus
- Overrides toString method to add department and salary into the output
A subclass Faculty that:
- Overrides computeBonus ( ) such that if hours are greater than 40, there will be %25 bonus for each additional hour
added to salary
- Overrides compteSalary ( ) such that salary = (rate * hours) + bonus
- Overrides toString method to add department and salary into the output
A subclass Student that has:
- Three additional private instance variables major, level, and grade
- An appropriate constructor to use constructor of superclass in defining those of the subclass
- One instance method computeGrade( ) to return the grade
- Overrides toString method to add major and level into the output
- Accessors
A subclass Undergrade that has:
- Three additional private instance variables named course1, course2, and course3 as double
- An appropriate constructor to use constructor of superclass in defining those of the subclass
- Overrides computeGade( ) such that grade = [(course1 + course2+ course3) / 300 ] * 100
- Overrides toString method to add grade into the output
- Accessors
A TestUniv class that has:
- The main function to run your code.
- Create objects to show two different outputs like:
Output 1:
Welcome, Ahmed Abdullah. Your ID is 123456
Your department is Computer Science and Engineering
Your salary for this month is 10,000
Step by step
Solved in 4 steps with 2 images