1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Assoli18 [71]
2 years ago
13

Write a program that reads from the user any three points in two dimensional space: x1, y1, x2, y2, x3, y3. Assume these points

form a line segment, (x1, y1) to (x2, y2) to (x3, y3). Calculate the sum of these line segments and print value to two decimal places.For example with points (0.0, 0.0), (3.0, 4.0), (6.0, 8.0), the distance for the first segment is 5.0, the second segment is 5.0, so the output for this case would be 10.00. The input and output for this case would be:INPUT:0.0 0.03.0 4.06.0 8.0OUTPUT: 10.00
Computers and Technology
1 answer:
netineya [11]2 years ago
6 0

Answer:

The solution code is written in Python:

  1. import math  
  2. coord= input("Enter coordinates for three points: ")
  3. coordList = coord.split(" ")
  4. for i in range(0, len(coordList)):
  5.    coordList[i] = float(coordList[i])
  6. seg_1 = math.sqrt((coordList[0] - coordList[2])**2 + (coordList[1]- coordList[3])**2)
  7. seg_2 = math.sqrt((coordList[2] - coordList[4])**2 + (coordList[3]- coordList[5])**2)
  8. print(seg_1 + seg_2)

Explanation:

Firstly, we can use Python built-in method <em>input()</em> to get coordinates for three points from user (Line 3). To simplify the entry process, the input of the three coordinates is expected in a single string 0.0 0.0 3.0 4.0 6.0 8.0O. Please note each of the coordinates is separated by a single space.

Next, we can proceed to use Python string split() method and single space character " " as separator to break the input string of coordinates into a list of individual numbers ["0.0", "0.0", "3.0", "4.0", "6.0", "8.0"].

Prior to calculating the line segment, it is important to ensure the coordinates in the list,<em> coordList</em>, have been converted from string to float type (Line 6 - 7).

Next, we are ready to apply the Distance formula to calculate the length of the two line segments that join the three coordinates (Line 9 and Line 11).  The distance formula is \sqrt{ (x1 - x2){^2}  +  (y1 - y2){^2}   }

At last, sum up the two line segments, <em>seg_1 </em>& <em>seg_2 </em>and print it in the terminal (Line 13).

You might be interested in
Help , i couldn’t find this answer
Aleksandr-060686 [28]

Answer:

Internet Explorer

Explanation:

4 0
3 years ago
Ronald attended a seminar about the best practices to use when browsing the Internet. The presenter used the following statement
Salsk061 [2.6K]

Answer:

Ronald missed the words: One-time password, Secure  

Explanation:

Whenever we use public computer, there are possibilities to steal the user data by hackers. It might not be safe to use as like we have protection in personal or Office computers. But when a situation arises to use a public system, it is always recommended to use one-time password so that the logins are not misused thereafter.

Even if the hackers try to misuse, the user will get a message / authentication reply to use the login and thus we are safe. Also, always browse only secured website ie. “https”.

8 0
3 years ago
Read 2 more answers
What are the four steps of the research process?
pishuonlain [190]

Answer:

Step 1: Identify the Problem

Step 2: Review the Literature. ...

Step 3: Clarify the Problem Step 4: Clearly Define Terms and Concepts.

7 0
3 years ago
What is the value of x after this statement?<br><br> double x = 2.0 / 5.0;
Step2247 [10]

Answer:

Exact Form:

x

=

2

_

5

Decimal Form:

x = 0.4

Explanation:

5 0
2 years ago
Read 2 more answers
8-16 Value of Dividends and Future Price A firm is expected to pay a dividend of $2.05 next year and $2.35 the following year. F
IgorC [24]

Answer:

$91.40

Explanation:

See attached picture.

3 0
3 years ago
Other questions:
  • Which of the following attacks is MOST likely the cause when a user attempts to go to a website and notices the URL has changed?
    10·1 answer
  • Each time the enter key is pressed, word creates a new paragraph. (points : 2) true false
    7·1 answer
  • It's inventiveness uncertainty and futuristic ideas typically deals with science and technology ......what is it.
    8·1 answer
  • Ex: If the input is: Pat Silly Doe the output is: Doe, P.S.
    9·1 answer
  • Which of the following is an example of an open-ended question?
    15·1 answer
  • PLZ HELP ASAP
    13·1 answer
  • 8. What do you believe: should husbands make decisions for their wives.
    5·1 answer
  • What is a personal data?
    12·1 answer
  • put together a shopping list of items that a first responder should always have at immediate disposal in a field kit. Using curr
    11·1 answer
  • What are the different elements of a window?​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!