Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a code in C++ only in one cpp file. The equation of a line in standard form is ax + by = c, wherein

Write a code in C++ only in one cpp file.

The equation of a line in standard form is ax + by = c, wherein both a and b cannot be zero, and a, b, and c are real numbers. If b 0, then a/b is the slope of the line. If a = 0, then it is a horizontal line, and if b = 0, then it is a vertical line. The slope of a vertical line is undefined. Two lines are parallel if they have the same slope or both are vertical lines. Two lines are perpendicular if either one of the lines is horizontal and the other is vertical or the product of their slopes is 1. Design the class Line to store a line. To store a line, you need to store the values of a (coefficient of x), b (coefficient of y), and c. Your class must contain the following operations: a. If a line is nonvertical, then determine its slope. b. Determine if two lines are equal. c. Determine if two lines are parallel. d. Determine if two lines are perpendicular. e. If two lines are not parallel, then find the point of intersection. Add appropriate constructors to initialize variables of Line. Also write a program to test your class. Note : Use of this pointer is mandatory where required(in function isParallel). You are not allowed to use any cin and cout in implementation of functions.

The class should be defined as under :-

class Line { private: double a; double b; double c; public: Line(double, double, double); double calculateGradient(); bool isEqual(Line l); bool isParallel(double, double, double); bool isPerpendicular(Line l); double calculateYIntercept(); void calculatePointOfIntersection(Line l, double &x, double&y); };

THANX in advance.

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago