Lab Seven

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

LAB # 7

TASK DESCRIPTION
A point in a Cartesian co-ordinate system is identified by a pair of x and y co-
ordinates. While a straight line in the same system is defined by a minimum of
two such points. The slope of the line is its inclination from the x – axis and is
calculated by dividing the difference of y co-ordinates by the difference of x co-
ordinates.

SUB TASK ONE:


Write a class definition for the object point having x and y co-ordinate as its data
members. Also define the functionality of taking input and displaying the member
values. The points initial co-ordinates should be (0,0).

SUB TASK TWO:


Write a class definition for the object line having two points and a slope as its
data members. Define the functionality for the user to provide inputs for the co –
ordinates of the point, calculating the slope, and displaying the values of its data
members. In the input function perform a check if the co – ordinates of the two
points are same. The program should keep asking for new co – ordinates for the
points till they are same. Overload the relational operator (==) to compare the
two points.

SUB TASK THREE:


The relation between two straight lines could be defined as follows:
Parallel: If the two lines have same slope
Intersecting: If the two lines have different slope

In the main() function create three lines and ask the user to input the co –
ordinates for the two points. Finally identify and display the relation that exists
between each of the three lines. Overload the symbol ( # ) to compare the slope
of any two lines.

You might also like