Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is a java related question i need solution for these: Q no: 1 Consider a class named Calculations with four overloaded functions i.e. 1.

this is a java related question i need solution for these:

Q no: 1

Consider a class named Calculations with four overloaded functions i.e.

1. Check_even(int),

2. Find_factorial(float),

3. division(float,float), and

4. multiplication(int,int).

In the main function, create an object of class Calculations and invoke its

member functions while passing parameters.

Q no: 2

Consider a class named Animal having typical function named eat that

accepts a parameter of type string.

Three classes i.e. Herbivore, Carnivore, and Omnivore have been

inherited from Animal class. All these classes i.e. Herbivore, Carnivore,

and Omnivore must have their own (overridden) eat function.

In the main function, create instances of Herbivore, Carnivore, and

Omnivore classes and invoke eat function with appropriate string

parameter to display the liking of that animal in eating.

Q no: 3

Create a class named Person, which contains

1. A function named print() to display the records of a person

2. Two data fields i.e. personName and age

A class named Patient inherits Person class, which contains

1. Two data fields i.e. disease type and recommended Medicine

2. Overridden function print() to display all details relevant to a patient

along with name and age using super keyword

A class named MedicarePatient inherited from class Patient, which

holds

1. A data field representing the name of the hospital

2. A data filed representing the name of the ward

3. A data field representing room number

4. Overridden function print() to display all details relevant to a patient

using super keyword.

Q no: 4

Create a class named GeometricShape containing

1. Two data fields i.e. shapeType (a string) and area (of type double)

2. A no-argument constructor to initialize all data fields with default

values "NoShape" and 0.0

3. A member function named computeArea() with returning value of

area data field

4. A member function named show() to display the details associated

with an instance of this class

Derive a class named Rectangle from class GeometricShape that

includes:

1. data members for the length and width of a rectangle

2. Setter and getter functions to set and get values of length and width,

and

3. overriding function named computeArea() to compute the area of

rectangle (length x width)

4. overriding function named show() to display the details associated

with an instance of class Rectangle

From the Rectangle class, derive a class named Cuboid that contains

1. a data field named height in addition to length and width,

2. two functions named setHeight and getHeight() to set and get value of

height data field, and

3. an overriding function named computeArea() to calculate the area of

a cuboid (length x width x height)

4. overriding function named show() to display the details associated

with an instance of class Cuboid

Implement these classes and in the main() create instances of each class

and test the functionality of overridden member functions with these

instances.

i need all 4 questions code

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions