Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ conduct the following 1. Create a class Player that has data items such as Pname, Pweight, Pheight, Pcountry. Initialize the data values in

Using C++ conduct the following

1. Create a class Player that has data items such as Pname, Pweight, Pheight, Pcountry. Initialize the data values in the default constructor. Create another constructor that assign the values to the Pname, Pweight, Pheight, Pcountry of the object. Create function to read the data values of the class variables from users in a method called get_data, make sure that user do not enter a negative value for Pweight and Pheight, if user attempts to enter a negative value then program should ask to enter again. Create a function to calculate the ratio of Pweight to Pheight and return the value for a Player. Create two objects of class Player one by using default constructor and other by using second constructor and print out the data of the Player, which has more Pweight. Also print out the data if the Plyer who has more ratio of Pweight to Pheight.

2. Create a class Student that has name, id, registered courses and tuition fees rate per course. Initialize the data values in the default constructor. Create another constructor that assign the values to name, id, registered courses and tuition fees rate per course of the object Create function that read the data values of the class variables from user. Create a function that display the data of an object. Create a function that calculates and return the amount of total tuition fee paid which is registered course times tuition fee rate per course. Create two objects of class Student and print out the data of the student who has paid more tuition.

3. Create a class Rectangle that has data items such as length, width and height as double. Initialize the data values in the default constructor. Write get methods for each data items. Write set methods for each data items to assign a value to a data item. Write a method called calc_area that calculates area (which is length * width) of the rectangle and return the result as double value. Write a method called calc_ratio that calculates ratio (height / width) of the rectangle and return the result as double value. Write another method called calc_vol that calculates the volume of rectangle which is volume= + 2 the method return the volume variable. Create two objects of class Rectangle, and read data of the class variables and find out area, ratio and volume of both objects and display.

4. Create a class hotel, which has hotel name, hotel address, number of guests, price per room, and number of rooms. Write one method, which reads data of class variables. Write a method called calc_ratio that calculates ratio (number of guests / number of room) of the hotel and return the result as double value. Write a display method to display the values of the class variables. Create two objects of hotel and printout the data of the object, which has more rooms, and print out the data of the object, which has more number of guests. The program also print out the data of the object which has lower ratio value.

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

What is the purpose of a balance sheet?

Answered: 1 week ago