Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Java program:
The class diagram with four classes Mammal, Human, Student and Doctor is given. The Mammal class is given as well. Write down the remaining classes as described in the class diagram. The fields and methods for each class is given in the attachment.
//in Mammel.java
Public interface Mammal{
public double hairColor():
}
1. Class Human:
- Fields: age(int), weight(double), height(double)
- Methods: getAge, getWeight, getHeight
2. Class Student:
- Fields: major (String), gpa (double), creditHours (int)
- methods: getMajor: returns major, getGpa: returns gpa, getYear: returns freshman, sophmore, junior, senior as determined by earned credit hours
- Freshman : less than 32 credit hours
- sophmore: at least 32 but less than 64 credit hours
- junior: at least 64 credit hours but less than 96 credit hours
- senior: at least 96 credit hours
3.Class Doctor:
- Fields: years(int), Speciality (String)
- methods: getYears: returns years, getSpeciality: returns speciality, getSalary: calculates salary. base salary is 40,000 for the first year and for each additional year gets 5000 more. so in second year doctor gets 45000 and so on.
4. Write another client class.
- create an object of class Student
- Called Alex whose major is CS, GPA is 3.4, credit hours is 54, height is 170 cm, weight is 150 pounds and age is 18.
- create an object of class Doctor
- called Jack whose speciality is "Dermatology", years is 4, height is 173 cm, weight is 179 pounds and age is 40.
- print out the students major, gpa, year, and age
- print out the doctor's speciality, height, weight, and salary.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 5) Consider the Clock class, which represents the passage of time. The tick() method adds one minute to the time on the clock. public class Clock ( public Clock () public void setHour (int x) (hour - x; } public void setMin (int x) public int getHour () public int getMin () (hour - minute = 0;} {minute - X: } (return hour; } (return minute; } public void tick () ++minute: if (minute >= 60) (minute minute 60; ++hour: hour hour 8 121 private int hour; private int minute; b) Write an overload method tick(int x) which adds x seconds to the time on the clock. Note that x might be greater than 60.arrow_forwardThe following code is in Java: public class Vehicle // Superclass { private double cost; public Vehicle(double c) { cost = c; } (Other methods . . .) // assume these are given and they’re OK. } public class Car extends Vehicle // Subclass { private int passengers; public Car(int p) { passengers = c; } (Other methods . . .) // assume these are given and they’re OK. } 1) What problems are in the code above?2) What is needed to fix the issue of the code?arrow_forwardFind the error(s) in the following class definition: public class TestClass private int value1; private int value2; public void TestClass(int num1, int num2) { value1= num1; value2 = num2; }arrow_forward
- Write a java program as shown in the following UML class diagram:(read the details below)arrow_forwardThe class Thingy is defined as shown below. public class Thingy {private int stat; public Thingy(int s) {stat = s;}public int getStat() {return stat;}public void setStat(int s) {stat = s;}} The code below appears in the main method of another class. What is printed when it is run? Thingy t = new Thingy(13);t.setStat(7);System.out.println(t.getStat());arrow_forwardFinish the constructor for the KickBall class. public class Ball { public double diameter; public Ball(double diam) { diameter = diam; public class KickBall extends Ball private Color ballColor; public KickBall(double diam, Color ballColor) {arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education