Designing class to denote person-s height

Assignment Help Programming Languages
Reference no: EM1346033

Q1) Design a class, PersonHeight, to denote the person's height. Our class will include the following members:

a) A data member to hold the meter value
b) Another data member to hold the centimeter value
c) The corresponding get/set methods for the given data members
d) Overload - operator so that the difference of two instances of PersonHeight can be calculated.
e) Overload > operator to compute if a PersonHeight object is greater than another one.
f) Overload == operator to compute whether two PersonHeight objects are equal or not.
g) Overload != operator for PersonHeight class. ( != operator will return "true" if the heights of two given operands are not equal, "false" otherwise.)
To test your class in the main function, use the operators and methods you have implemented. Test your program by reading 7 pairs of meter-centimeter values from the user. Also, try using array of objects.

2. Think about how to overload the above operators as non-member functions
---
I create a class
PersonHeight{
int meter=0;
int centimeter=0;
}
void get m_value() {
return meter;}
void get c_value() {
return centimeter;}
void set m_value(int m) {
meter=m;}
void set m_value(int c) {
centimeter=c;}

Reference no: EM1346033

Questions Cloud

Illustrate what are costs associated with this non-native : Illustrate what are the costs associated with this non-native species.
Finding different sizes of newspaper for local newspaper : Comprise a specific recommendation regarding how many different sizes newspaper must offer.
Explain advantages to borrowing short term : Discuss and explain some advantages and disadvantages of having a bad credit vs good credit in terms of getting a loan?
Find the effective annual rate : Bank A provides loans with a 10 percent stated yearly rate and a 10 percent compensating balance. You wish to obtain $250,000 in a 6 month loan.
Designing class to denote person-s height : Design a class, PersonHeight, to denote the person's height. Our class will include the following members.
Calculate the average power output on the way up : A car is traveling at a constant speed of 38.8m/s on a highway. At the instant this car passes an entrance ramp, a second car enters the highway from the ramp. The second car starts from rest and has constant acceleration. What acceleration must it..
Communication plan - barriers presentation : Communication Plan - Barriers Presentation - Prepare a Microsoft PowerPoint presentation
Universal life policy : The given table provides data about a universal life policy. Fill in the Table Year 1 Year 2 Year 3 Cash value at starting of year $10,000
Sustain leader communication : Explain the importance of reinforcing leadership messages and why do some leaders undervalue reinforcing key messages?

Reviews

Write a Review

Programming Languages Questions & Answers

  Create a project in xcode

Create a new project in XCode using the Mac OS X/Command Line Tool template

  Program-customer-s names phone numbers in alphabetical order

Load file into parallel arrays and display list of customers' names and phone numbers in alphabetical order.

  Distinguishing web pages or web servers for task

Distinguish between any Web pages or Web servers you would use for this task.

  Javascript for metric conversions

Write a javascript that will assist the user with metric conversions. Your program should allow the user to specify the names of the units as strings.

  Program for class quiz to implement measurable interface

State a class Quiz to implement Measurable interface. A quiz has a score and a letter grade (such as B+).

  Program to compute unit price of items sold

Manager of a Supermarket would like to be able to calculate the unit price of items sold there. To do this the program should input the name and the price of the item.

  Development of the current strategic potential of airline

Evaluate the organisation's current external and internal strategic position

  Ethics and social responsibility

Ethics and social responsibility at McDonalds

  Questions on programing problem with the process of analysis

Questions on Programing Problem with the process of analysis and reflection that went on as you developed the project.

  Implicit unsafe type conversions-statements and expressions

Write a report using APA format for references that researches the definition of the language with respect to implicit unsafe type conversions in both assignment statements and expressions.

  Explaining object hierarchy in object-oriented programming

Study the concept of inheritance and the object hierarchy in object-oriented programming, and write a paper comparing these concepts with the concept of inheritence.

  C program to accept three numbers inputs by user

Write down C program to accept three numbers input by a user, and outputs a table of temperatures in Fahrenheit, Celsius, and Kelvin.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd