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]
3 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]3 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
Write an application named [LastName]_MultiplicationTable and create a method that prompts the user for an integer value, for ex
WITCHER [35]

Answer:

I did this in C# & Java

Explanation:

C#:

       public static void Main(string[] args)

       {

           int input = Convert.ToInt32(Console.ReadLine());

           Multiply(input);

       }

       public static int Multiply(int input)

       {

           int ans = 0;

           for(int i =1; i<=10; i++)

           {

               ans = i*input;

               Console.WriteLine(i + "*" + input + "=" + ans);

           }

           return ans;

       }

Java:

   public static void main(String[] args)

   {

       Scanner myObj = new Scanner(System.in);  

       int input = Integer.parseInt(myObj.nextLine());

       Multiply(input);

   }

   public static int Multiply(int input)

   {

       int ans = 0;

       for(int i =1; i<=10; i++)

           {

               ans = i*input;

               System.out.println(i + "*" + input + "=" + ans);

           }

       return ans;

   }

7 0
3 years ago
Given the following structure and variable definitions, struct customer { char lastName[ 15 ]; char firstName[ 15 ]; unsigned in
garri49 [273]

Answer:

see explaination

Explanation:

a)

customerRecord.lastName

b)

customerPtr->lastName or (*customerPtr).lastName

c)

customerRecord.firstName

d)

customerPtr->firstName or (*customerPtr).firstName

e)

customerRecord.customerNumber

f)

customerPtr->customerNumber or (*customerPtr).customerNumber

g)

customerRecord.personal.phoneNumber

h)

customerPtr->personal.phoneNumber or (*customerPtr).personal.phoneNumber

i)

customerRecord.personal.address

j)

customerPtr->personal.address or (*customerPtr).personal.address

k)

customerRecord.personal.city

l)

customerPtr->personal.city or (*customerPtr).personal.city

m)

customerRecord.personal.state

n)

customerPtr->personal.state or (*customerPtr).personal.state

o)

customerRecord.personal.zipCode

p)

customerPtr->personal.zipCode or (*customerPtr).personal.zipCode

6 0
3 years ago
Go to the Subset tab, which gives a subset of randomly chosen data from the first tab. Go to your Math Tools and open the Graph
Karo-lina-s [1.5K]

A linear regression model is used to show the relationship between variables on a scatter plot

The equation of the linear regression model is: \^y = 1.56\^x + 1.29 and the correlation coefficient is 0.8034

<h3>How to determine the equation of the linear regression</h3>

The question is incomplete. So, I will make use of a dataset that has the following calculation summary (from a graphing calculator)

  • Sum of X = 45
  • Sum of Y = 83
  • Mean X = 4.5
  • Mean Y = 8.3
  • Sum of squares (SSX) = 82.5
  • Sum of products (SP) = 128.5
  • The value of R is 0.8034.

The equation of the linear regression model is:

\^y = 1.56\^x + 1.29

See attachment for the scatter plot

Read more about linear regression model at:

brainly.com/question/26347582

5 0
2 years ago
Create a program called "Geometry" Prompt the user for a small decimal number. Prompt the user for a large decimal number. Using
skelet666 [1.2K]

Answer:

In Python:

import random

small = float(input("Small: "))

large = float(input("Large: "))

radius = round(random.uniform(small, large),2)

volume = round(4/3 * 22/7 * radius* radius* radius,2)

print("Radius: "+str(radius))

print("Volume: "+str(volume))

Explanation:

This imports the random module

import random

The next two lunes prompt the user for small and large decimal number

small = float(input("Small: "))

large = float(input("Large: "))

This generates the radius

radius = round(random.uniform(small, large),2)

This calculates the volume

volume = round(4/3 * 22/7 * radius* radius* radius,2)

This prints the generated radius

print("Radius: "+str(radius))

This prints the calculated volume

print("Volume: "+str(volume))

<em>Note that, the radius and the volume were approximated to 2 decimal places. Though, it wasn't stated as part of the program requirement; but it is a good practice.</em>

8 0
3 years ago
Create your own unique Java application to read all data from the file echoing the data to standard output. After all data has b
mafiozo [28]

Answer:

<u>Output</u>

The values read are:  

25

3

4

65

7

9

5

6

1

11

10 data values were read

Explanation:

Below is the Java program to read all data from the file echoing the data to standard output and finally displaying how many data were read:-

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class MyFileReader {

public static void main(String[] args){

 int num,counter=0;

 File file=new File("numbers.txt");

 try {

  Scanner input=new Scanner(file);

  System.out.println("The values read are: ");

  while(input.hasNext()){

   num=input.nextInt();

   System.out.println(num);

   counter+=1;

  }

  System.out.println(counter+" data values were read");

 } catch (FileNotFoundException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

 }

}

}

8 0
4 years ago
Other questions:
  • whats something that u want to do but ur parents wont allow it like having a phone or going to a college ​
    11·2 answers
  • HELP I don't understand this
    14·2 answers
  • PLEASE HELP
    12·2 answers
  • Write a program that use a switch statement whose controlling expression is the variable area code. If the value of area_code is
    12·1 answer
  • Could someone give an example or tell me what all of these mean? (For internet source citing)
    10·1 answer
  • Your program should first save 10 random numbers from 1-100 to an array called aray
    12·1 answer
  • Lol fortnite really going UwU and anime
    12·2 answers
  • Write down the different types of testing with their definition.
    11·1 answer
  • C. List three obstacles to effective listening.
    8·1 answer
  • A museum is evaluating historical documents for authenticity, reviewing their physical condition, and categorizing them by subje
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!