Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Line Formulas Create a program called LineFormulas. In your main method, ask the user to type in four values, one at a time x1, x2,

image text in transcribedimage text in transcribed
Line Formulas Create a program called LineFormulas. In your main method, ask the user to type in four values, one at a time x1, x2, y1, y2, representing the endpoints [3:1, X2} and (y1, y2} ofa line segment. These variables should all be doubles. Next, display the following menu (in your main method): 1. Slope of the line segment 2. Midpoint of the line segment The user should be asked to type in either 1 or 2 based on which calculation they would like to perform [See the next page for some examples). You can use either a switch [with a default case to print an error message], or iffelse iffelse statements, whichever you prefer. It is not necessary to include a loop for this program. 1} If the user chooses menu option 1, call a Style 2 method named slape that has 4 double parameters x1, x2, y1, y2, and caICuIates and prints the slope, using the formula: y2_y1r X2_x1 2} If the user chooses menu option 2, call a Style 2 method named midpoint that has 4 double parameters x1, x2, y1, y2, and calculates and prints the midpoint of the line. This re uires two calculations: \" xnxz =m+s M= M x 2 V 2 Print the midpoint in [M1, My] form, including the brackets and comma. Sample output 1: run: Please type in a value for x1: 1.5 Please type in a value for x2: 2.5 Please type in a value for y1: 5.5 Please type in a value for y2: 8.5 1. Slope of the line segment 2. Midpoint of the line segment Please make a selection from the menu above (1 or 2): 1 The slope is: 3.0 BUILD SUCCESSFUL (total time: 8 seconds) Sample output 2: run: Please type in a value for x1: 1.5 Please type in a value for x2: 2.5 Please type in a value for y1: 5.5 Please type in a value for v2: 8.5 1. Slope of the line segment 2. Midpoint of the line segment Please make a selection from the menu above (1 or 2): 2 The midpoint is: (2.0, 7.0) BUILD SUCCESSFUL (total time: 8 seconds)

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Note: Need help with the public boolean addAll(CiscList

Answered: 1 week ago