The equation of a straight line is written as y = mx + b where m is the slope of the line and b is the value of y when x = 0. If there are two coordinate points of the line are given, then it is very easy to compute the line equation. Also you can find the distance between two points. Problem: Write a program to compute lines equation for a set of lines. The number of lines is read from the user. Each line is computed by generating two points randomly using Point2D API. In addition, distance between two points is computed. The program should display a table which include all information about each line. See sample runs below. Take into consideration: 1. Number of generated lines should be greater than zero. 2. Two point objects are constructed only once. Then just update the location of two points for each line using Point2D API methods. 3. x and y values of each point are generated randomly to be less than 100 and greater than 0. 4. Compute the distance between two points using Point2D API methods. 5. A line has two special cases: horizontal line (m = 0), vertical line( m is undefined).

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 30PE
icon
Related questions
Question
100%
The equation of a straight line is written as y = mx + b where m is the slope of the line and b is the value of y when x = 0. If there are two coordinate points of the line are given, then it is very easy to compute the line equation. Also you can find the distance between two points. Problem: Write a program to compute lines equation for a set of lines. The number of lines is read from the user. Each line is computed by generating two points randomly using Point2D API. In addition, distance between two points is computed. The program should display a table which include all information about each line. See sample runs below. Take into consideration: 1. Number of generated lines should be greater than zero. 2. Two point objects are constructed only once. Then just update the location of two points for each line using Point2D API methods. 3. x and y values of each point are generated randomly to be less than 100 and greater than 0. 4. Compute the distance between two points using Point2D API methods. 5. A line has two special cases: horizontal line (m = 0), vertical line( m is undefined).
Introduction:
The equation of a straight line is written as y = mx + b where m is the slope of the line and
b is the value of y when x = 0. If there are two coordinate points of the line are given, then
it is very easy to compute the line equation. Also you can find the distance between two
points.
Problem:
Write a program to compute lines equation for a set of lines. The number of lines is read
from the user. Each line is computed by generating two points randomly using
Point2D API. In addition, distance between two points is computed. The program should
display a table which include all information about each line. See sample runs below.
Take into consideration:
1. Number of generated lines should be greater than zero.
2. Two point objects are constructed only once. Then just update the
location of two points for each line using Point2D API methods.
3. x and y values of each point are generated randomly to be less than 100
and greater than 0.
4. Compute the distance between two points using Point2D API methods.
5. A line has two special cases: horizontal line (m = 0), vertical line( m is
undefined).
1|
Samples run of the program:
Sample 1
Please enter how many Line equations you would Like to generate: -4
Error: Enter integer value > 0... Try Again
Please enter how many Line equations you would Like to generate: 4
Line No
P1(x1, y1)
P2(x2, y2)
Distance
Line Equation
P1(3.50 , 77.37)
P1(77. 88, 98.96)
P1(87.99, 60.72)
P1(67.82, 20.50)
P2(3. 50 , 90. 26)
P2(85.02, 35.52)
P2(2.13 , 77.14)
Р2 (53.78, 20.50)
1
12.89
x=3.50
y=-8.89x + 790,92
y=-0.19x + 77, 54
2
63.84
3
87.41
4
14.04
y= 20.50
Sample 2
Please enter how many Line equations you would Like to generate: d
Error: It is not integer value...Exit
Transcribed Image Text:Introduction: The equation of a straight line is written as y = mx + b where m is the slope of the line and b is the value of y when x = 0. If there are two coordinate points of the line are given, then it is very easy to compute the line equation. Also you can find the distance between two points. Problem: Write a program to compute lines equation for a set of lines. The number of lines is read from the user. Each line is computed by generating two points randomly using Point2D API. In addition, distance between two points is computed. The program should display a table which include all information about each line. See sample runs below. Take into consideration: 1. Number of generated lines should be greater than zero. 2. Two point objects are constructed only once. Then just update the location of two points for each line using Point2D API methods. 3. x and y values of each point are generated randomly to be less than 100 and greater than 0. 4. Compute the distance between two points using Point2D API methods. 5. A line has two special cases: horizontal line (m = 0), vertical line( m is undefined). 1| Samples run of the program: Sample 1 Please enter how many Line equations you would Like to generate: -4 Error: Enter integer value > 0... Try Again Please enter how many Line equations you would Like to generate: 4 Line No P1(x1, y1) P2(x2, y2) Distance Line Equation P1(3.50 , 77.37) P1(77. 88, 98.96) P1(87.99, 60.72) P1(67.82, 20.50) P2(3. 50 , 90. 26) P2(85.02, 35.52) P2(2.13 , 77.14) Р2 (53.78, 20.50) 1 12.89 x=3.50 y=-8.89x + 790,92 y=-0.19x + 77, 54 2 63.84 3 87.41 4 14.04 y= 20.50 Sample 2 Please enter how many Line equations you would Like to generate: d Error: It is not integer value...Exit
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT