Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3.11 (MotorVehicle class) Create a class called MotorVehicle that represents a motor vehicle using: make (type string), fuelType (type string), yearOfManufacture (type int), color (type

3.11 (MotorVehicle class) Create a class called MotorVehicle that represents a motor vehicle

using: make (type string), fuelType (type string), yearOfManufacture (type int), color (type string)

and engineCapacity (type int). Your class should have a constructor that initializes the three

data members. Provide a set and a get function for each data member. Add a member function

called displayCarDetails that displays the five data members in five separate lines in the form

"member name: member value". Write a test program to demonstrate MotorVehicles capabilities.

3.15 (Target-Heart-Rate Calculator) While exercising, you can use a heart-rate monitor to see

that your heart rate stays within a safe range suggested by your trainers and doctors. According to

the American Heart Association (AHA) (http://bit.ly/AHATargetHeartRates), the formula for

calculating your maximum heart rate in beats per minute is 220 minus your age in years. Your target

heart rate is a range thats 5085% of your maximum heart rate. [Note: These formulas are estimates

provided by the AHA. Maximum and target heart rates may vary based on the health, fitness and

gender of the individual. Always consult a physician or qualified health-care professional before

beginning or modifying an exercise program.] Create a class called HeartRates. The class attributes

should include the persons first name, last name and date of birth (consisting of separate attributes

for the month, day and year of birth). Your class should have a constructor that receives this data as

parameters. For each attribute provide set and get functions. The class also should include a member

function that calculates and returns the persons age (in years), a member function that calculates

and returns the persons maximum heart rate and a member function that calculates and returns the

persons target heart rate. Write a program that prompts for the persons information, instantiates

an object of class HeartRates and prints the information from that objectincluding the persons

first name, last name and date of birththen calculates and prints the persons age in (years), maximum

heart rate and target-heart-rate range.

3.9 (Modified Account Class) Modify class Account (Fig. 3.8) to provide a member function

called withdraw that withdraws money from an Account. Ensure that the withdrawal amount does

not exceed the Accounts balance. If it does, the balance should be left unchanged and the member

function should display a message indicating "Withdrawal amount exceeded account balance."

Modify class AccountTest (Fig. 3.9) to test member function withdraw.

// Fig. 3.8: Account.h

2 // Account class with name and balance data members, and a

3 // constructor and deposit function that each perform validation.

4 #include

56

class Account {

7 public:

8 // Account constructor with two parameters

9 Account( )

10 : name{accountName} { // assign accountName to data member name

11

12 // validate that the initialBalance is greater than 0; if not,

13 // data member balance keeps its default initial value of 0

14

15

16

17 }

18

19

20

21

22

23

24

25

26

27

28

29

30

31 // function that sets the name

32 void setName(std::string accountName) {

33 name = accountName;

34 }

35

36 // function that returns the name

37 std::string getName() const {

38 return name;

39 }

40 private:

41 std::string name; // account name data member

42

43 }; // end class Account

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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

What is the difference between R and Ru? How are these two related?

Answered: 1 week ago

Question

10. Describe the relationship between communication and power.

Answered: 1 week ago