Create a program that uses a Java method to determine the length of a line by inputting the X,Y coordinates of the line endpoints. Show the result with a precision of four decimal places.

Answers

Answer 1

Answer:

import java.lang.Math;

import java.util.Scanner;

class lineLength {

 private double x1;

 private double x2;

 private double y1;

 private double y2;

 public lineLength(double x1, double y1, double x2, double y2){

   this.x1 = x1;

   this.x2 = x2;

   this.y1 = y1;

   this.y2 = y2;

   

 }

 public String toString(){

   double length = Math.sqrt( ( ( this.x2 - this.x1 ) * ( this.x2 - this.x1 ) ) + ( ( this.y2 - this.y1 ) * ( this.y2 - this.y1 ) ) );

   String answer = String.format("%.4f %n", length);

   return answer;

 }

}

class Main{

 public static void main(String[] args) {

   Scanner scanner = new Scanner(System.in);

   System.out.println("Please input x1, y1, x2, and y2");

   double x1 = scanner.nextDouble();

   double y1 = scanner.nextDouble();

   double x2 = scanner.nextDouble();

   double y2 = scanner.nextDouble();

   lineLength test = new lineLength(x1,y1,x2,y2);

   System.out.println(test);

 }

}

Explanation:

we use formula

[tex]\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}[/tex]


Related Questions

3. Which of the following strategies will lower the conduction load in a building? (choose all that apply)
A. Lowering the U-factor
B. Raising the U-factor
C. Lowering the A in square feet
D. Raising the A in square feet
E. Lowering the AT
F. Raising the AT

Answers

Explanation:

Site the building carefully. ...

Use trees and other vegetation to shade the house. ...

Minimize size of windows on east and west; limit size on south. ...

Use low-solar-transmittance glazings to reduce solar gain. ...

Shade windows with architectural features.

why are laptops more expensive than desktop with same features and power

Answers

It has the added feature of being portable but mostly laptop under perform desktops

discuss about programming language make use of both interperter and complier?​

Answers

Answer:

I think High Level Language is the Programming language that makes use of both interpreter and compiler

What does a good SOW include?

a mission statement with summarized sections.
a mission statement with detailed sections
a broad statement with summarized sections
a broad statement with detailed sections

Answers

Answer:

a broad statement with summarized sections

Explanation:

What is keyword density?

Answers

Answer:

Keyword density is the percentage of times a keyword or phrase appears on a web page compared to the total number of words on the page. In the context of search engine optimization, keyword density can be used to determine whether a web page is relevant to a specified keyword or keyword phrase.

What are the different selection structures in the C programming language?

Answers

Answer:

SELECTION STRUCTURES

Selection statements allow you to control the flow of program execution on the basis of the outcome of an expression.

different selection structures are:

1)if statements

2)if-else statements

3)if-else-if statements

4)switch statements

Explanation:

THE IF STATEMENTS

the first statement in the if block is only executed when the specified condition is true.If the condition is false then the contained statement will be skipped and execution continued with the rest of the program.

example:

public class IfDemo

{

public static void main(String[] args) {

int age;

Scanner inputDevice = new Scanner(System.in);

System.out.print("Please enter Age: ");

age = inputDevice.nextInt();

if(age > 18)

System.out.println("above 18 ");

}

}

THE IF-ELSE STATEMENTS

if the specified condition in the if statement is false, then the statement after else will be executed.

example:

public class IfElseDemo

{

public static void main( String[] args )

{

int age;

Scanner inputDevice = new Scanner( System.in );

System.out.print( "Please enter Age: " );

age = inputDevice.nextInt();

if ( age >= 18 )

System.out.println( "above 18 " );

else

System.out.println( "below 18" );

}

}

THE IF-ELSE-IF STATEMENTS

the statements after else can be another if or if-else statement, multiple if-else statements.When the condition is true, the associated statement will be executed and remaining conditions will be bypassed.

example:

public class IfElseIfDemo

{

public static void main( String[] args )

{

int age;

Scanner inputDevice = new Scanner( System.in );

System.out.print( "Please enter Age: " );

age = inputDevice.nextInt();

if ( age >= 18 && age <=35 )

System.out.println( "between 18-35 " );

else if(age >35 && age <=60)

System.out.println("between 36-60");

else

System.out.println( "not matched" );

}

}

THE SWITCH STATEMENTS

It is a multi way branch statement. It defines multiple paths of execution of a program.It provides a better alternative than if-else-if statements.

example:

public class SwitchDemo

{

public static void main( String[] args )

{

int age;

Scanner inputDevice = new Scanner( System.in );

System.out.print( "Please enter Age: " );

age = inputDevice.nextInt();

switch ( age )

{

case 18:

System.out.println( "age 18" );

break;

case 19:

System.out.println( "age 19" );

break;

default:

System.out.println( "not matched" );

break;

}

}

}

The different types of selection structures in the C programming language are:

1) if statements2) if-else statements3) if-else-if statements4) switch statements

What is C programming language?

The sequence statement, selection statements (of which there are three variants: if, if...else, and switch), and repetition statements are the only three forms of control structures available in C++.

Due to the fact that C is compiled, it is a quicker language than Python. Since Python programs are interpreted, they typically run more slowly than C applications. When a variable is created in C, its type must be defined, and only values of that specific type are allowed to be given to it.

Therefore, the different selections of C programming languages are

1) if statements2) if-else statements3) if-else-if statements4) switch statements

To learn more about C programming language, refer to the link:

https://brainly.com/question/10937743

#SPJ2

A.Direction: identify the following examples of the ingredients used for sandwiches.

Answers

Answer:

i dont know how to answer may module because i dont have helper

What is the term given to large values of information collected from various sources?

A.
association
B.
classification
C.
neural networks
D.
big data

Answers

The term given to large values of information collected from various sources ; association.

What is the various?

The various can refer to a range of different things, depending on context. It could refer to different types of people, cultures, items, or anything else that can be seen as different or distinct from each other. It could also refer to different ways of looking at or doing something. For example, various methods of problem solving, various approaches to studying, various strategies for communication, etc. Ultimately, the various refers to the different options that exist in a given situation.

To learn more about various

https://brainly.com/question/26986135

#SPJ1

What purpose does encryption on the internet serve? Why is it so important?

Answers

Answer:

it keeps cybercriminals from stealing private information

Explanation:

hope this helps

how you are going to use the online platforms responsibly as a source of information you may cite an example on how will you comply to existing laws on use the online platforms​

Answers

Answer:

1. Don't post or say anything bad.

2. Stay away from the dark internet.

3. Don't hack people.

4. Be safe!

a researcher saved her draft work on a CD ROM from a friends computer with an intention of sending it to her supervisor by e-mail once she got home. however on reaching home she realized that her computer could not read a CD ROM. how can you advice her to have her work sent without physically going back to her friend?

Answers

Answer:

mail the cd to the supervisor

Explanation:

Which of these best describes the principle of least privilege? Users should have at least the privileges they need to do their jobs, and usually more. Users should have at least the privileges they need to do their jobs, and usually more. Only one system administrator should have the highest level of privileges. Only one system administrator should have the highest level of privileges. The fewer privileges users have, the better a network operates. The fewer privileges users have, the better a network operates. Users should have the minimum privileges needed to do their work. Users should have the minimum privileges needed to do their work.

Answers

The statement which best describes the principle of least privilege is: D. Users should have the minimum privileges needed to do their work.

What is principle of least privilege?

Principle of least privilege is also referred to as the principle of minimal privilege (least authority) and it can be defined as a security concept that involves giving an end user, software program, or process the least (minimum) levels of access and permissions necessary to perform  a work or an action in a database.

In this context, end users should have the least (minimum) privileges needed to do their work, in order to protect a database or network.

Read more on least privilege here: brainly.com/question/4365850

Answer:

Users should have the minimum privileges needed to do their work.

Explanation:

Ed22

Imagine that you need to prepare for three end-of-term tests. What steps will you take to make sure your study time is well spent?

Answer: I will choose a good study area. Then, I will use highlighting, notes, flash cards, and checklists to study for the tests.

Answers

Answer:

I will also choose a good study area and copy them and paste it

Answer:

Imagine that you need to prepare for three end-of-term tests. What steps will you take to make sure your study time is well spent?

Explanation:

i did it

13. You're emailing your grandparents. Which of the following is the best example of digital etiquette?
A. Typing in all caps because they wear glasses
B. Repeatedly teasing them in an attempt at humor
C. Pirating movies that they want to see
D. Spelling out words and avoiding slang

Answers

d. spelling out words and avoiding slang

Answer:

D

Explanation:

spelling out words and avoiding slang

Write pseudo code that performs the following: Ask a user to enter a number. If the

number is between 0 and 10, write the word blue. If the number is between 10 and

20, write the word red. if the number is between 20 and 30, write the word green.

If it is any other number, write that it is not a correct color option.​

Answers

Answer:
BEGIN
INPUT N
IF N>0 AND N<10 THEN
OUTPUT "blue"
ELSE
IF N>10 AND N<20 THEN
OUTPUT "red"
ELSE
IF N>20 AND N<30 THEN
OUTPUT "green"
ELSE
OUTPUT "It is not a correct color option"
ENDIF
END.

Explanation:

Ask a user to enter a number. If the number is between 0 and 10, write the word blue. If the number is between 10 and 20, write the word red. if the number is between 20 and 30, write the word green. If it is any other number, write that it is not the correct color option

pseudo-code is:

Write "Please enter a number"

Read colornum

If(colornum >0 and colornum <= 10)

Write blue

else If(colornum >10 and colornum <= 20)

Write red

else If(colornum >20 and colornum <= 30)

Write green

else

Write "not a correct color option"

What is pseudo code?Pseudocode is also called false code. Pseudocode is a natural way of programming description that does not require any strict programming language syntax or underlying technology considerations. In simple words, the pseudocode is the planning or designing program.  

To learn more about Pseudocode refer to:

https://brainly.com/question/24953880

#SPJ2

In your program, your ball dropped. What condition made the ball stop when it reached the origin of the axes you had drawn?

Answers

The condition that made the ball stop when it reached the origin of the axes you had drawn is the gravitational force that is of the interaction between two objects with mass.

What is the force that act on an object when you drop a ball?

The gravitational force is known to be a kind of interaction that exist between two objects with their mass.

Note that for a falling ball, the two objects with their known mass are said to be the Earth and also the ball. The power of this gravitational force is said to be proportional to the product of the two said masses.

Learn more about gravitational force from

https://brainly.com/question/72250

Answer:  while ball.pos.y > 0

Explanation: This is the aswer if you are looking fo the equation.

I won't to convert text to a table . what is the first step I should take ?

Answers

Answer:

Use paragraph marks to indicate where you want to begin a new table row. Select the text that you want to convert, and then click Insert > Table > Convert Text to Table. In the Convert Text to Table box, choose the options you want.

Explanation:

please put me in brainlest

What is the function of network security
It protects information from users.
It protects networks from intruders,
It secures networks from users,
It protects users from networks,

Answers

It protects users from networks

and other data from breaches intrusion and other threats.

Answer:

it protects netorks from intruders

Explanation:

i took the test

_________security may also be referred to as Information Technology security.

Answers

Answer:

Computer Security or Cybersecurity

Explanation:

Information Technology Security is the protection of computer systems and networks from information disclosure, theft of, or damage to their hardware, software, or electronic data.

Which type of testing requires the tester to enter erroneous data into an application?
A.
usability testing
B.
data comparison
C.
validation testing
D.
stress testing

Answers

A. Usability testjng


1. Welds made critical piping must be expertly
Completed, thoroughly inspected, and

Answers

Welds made on critical piping must be expertly​ completed, thoroughly​ inspected, and​ also at least as strong as the piping being welded.

What welding process is used on pipelines?

Welding processes are known to be the method that is used in a range of industries such as aerospace, automotive, energy, construction etc.

Pipe welding is known to be one that uses arc welding techniques, such as shielded metal arc welding (SMAW), gas metal arc welding (GMAW) and others. note that Welds that is done on critical piping have to be expertly​ completed, thoroughly​ inspected, and​ also at least as strong as the piping being welded.

Learn more about Welds from

https://brainly.com/question/5794222

Write the syntax of GOTO, ON GOTO and IF THEN ELSE with examples.​

Answers

Answer:

GOTO:

goto label;

... .. ...

... .. ...

label:

statement;

Example:

/ Program to calculate the sum and average of positive numbers

// If the user enters a negative number, the sum and average are displayed.

#include <stdio.h>

int main() {

  const int maxInput = 100;

  int i;

  double number, average, sum = 0.0;

  for (i = 1; i <= maxInput; ++i) {

     printf("%d. Enter a number: ", i);

     scanf("%lf", &number);

     

     // go to jump if the user enters a negative number

     if (number < 0.0) {

        goto jump;

     }

     sum += number;

  }

jump:

  average = sum / (i - 1);

  printf("Sum = %.2f\n", sum);

  printf("Average = %.2f", average);

  return 0;

}

Select the correct answer.
Derek works in the software quality assurance department. Which tools or process should Derek use to monitor and measure changes?
A.
software engineering process
B.
software quality metrics
C.
SQA audits
D.
reviews

Answers

Answer:

B: software quality metrics .

In Python
Create a conditional expression that evaluates to string "negative" if user_val is less than 0, and "non_negative" otherwise.
Sample output with input -9

Answers

The python program is an illustration of conditional expressions or conditionals statements, and they are used to make decisions

The Python program

The conditional expression written in Python, where comments are used to explain each action is as follows:

#This tests if user_val is less than 0

if user_val < 0:

#This prints "negative" if true

   print("negative")

else:

#This prints "non_negative" if true

   print("non_negative")

Read more about conditional statements at:

https://brainly.com/question/24833629

Write a 2 page paper explaining why a compiler needs to know about both the target architecture as well as the target OS.

Answers

The target architecture and the operating system are important to the compiler to perform high level executions which are made in programming language.

What is a compiler?

A compiler simply means a computer program that is important in the translation of codes that are written in a particular language to another programming language.

In this case, they're vital to perform high level executions which are made in programming language.

The target architecture also sets the framework for the planning and assigning of resources to reach a desired state.

Learn more about compiler on:

https://brainly.com/question/26175597

Spreadsheets are sometimes credited with legitimizing the personal computer as a business tool. Why do you think they had such an impact?

Answers

Spreadsheets is known to be an credited tool with legitimizing the personal computer as a business tool. Spreadsheets have a lot of impact in business world because:

It has low technical requirement. Here, spreadsheet does not need a complex installation and it is easy to understand.Data Sifting and Cleanup is very easy to do.It is a quick way to Generate Reports and Charts for business.

What is Spreadsheets?

Spreadsheets is known to be a key  business and accounting tool. They are known to have different complexity and are used for a lot of reasons.

The primary aim of this is that it helps us  to organize and categorize data into a kind of logical format and thus helps us to grow our business.

Learn more about Spreadsheets from

https://brainly.com/question/4965119

Problem: Write the Python code of a program called University Application that asks the user enter their name, age, and high school GPA. If the user is at least 18 years old and their school GPA is at least 2.75, display a message telling the user they eligible to apply to study that major. However, in case the user's GPA is below 2.75, display a message telling them that they are not eligible to apply to study at this university. If the user is 17 or 16 years old, and have a GPA of at least 3.0, display a message telling them they can apply for exceptional acceptance. If the user is younger than 16, tell them they must wait until they are older to apply.​

Answers

Th python code of a program that asks the user enter their name, age, and high school GPA and determine if they are eligible for admission is as follows:

x = input("please enter your name: ")

y = int(input("Enter your age: "))

z = float(input("Please enter your high school GPA: "))

if y >= 18 and z >= 2.75:

    print(f"You are eligible to apply to study your major")

elif y >= 18  and z < 2.75:

     print("You are not eligible to apply to study your major")

elif y == 16 or y == 17  and z >= 3.0:

    print("You can apply for exceptional acceptance")

else:

    print("You must wait until you are old to apply")

Code explanation:

The code is written in python.

The first variable stores the users name.The second variable stores the users age.The third variable stores the users high school GPA.If the users age is greater than or equals to 18 and his/her GPA is equal or greater than 2.75, the user is eligible. else if the users age is greater than or equals to 18 and his/her GPA is less than 2.75, the user is not eligible.else if the user age is 16 or 17 and his/her GPA is equals or greater than 3.0, then they can apply for exceptional acceptance. Else we will print that the users is not old enough to apply if he/she is less than 16 years.

learn more on python code here; https://brainly.com/question/13450046

A______data structure goes in order of arrival.
_______means First in, First out.
A _______data structure data is pushed onto the stack and uses _______
Last in, First out.

-queue
-FIFO
-LIFO
-stack

Answers

1.Queue

2.LIFO

3.FIFO


4.stack?
stack
fifo
queue
lifo

Cryptography is the science of secret writing. Cryptography involves creating written or generated codes that allow information to be kept secret.

a. True
b. False

Answers

Answer:

true

Explanation:

the answer is true dude

Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n’s, if the number of times the character appears is not eactly 1.
Ex if the input is: n Monday
the output is: 1 n
Ex: if the input is: z Today is Monday
The output is 0 z’s
Ex: if the input is: n It’s a Sunday day
the output is: 2 n’s
case matters
Ex: if the input is: n Nobody
the output is: 0 n’s
N is different than N.


I need help putting it in Java

Answers

Answer:

class Main {

 public static void analyzeString(char c, String s) {

   int count = 0;

   for(int i=0; i<s.length(); i++) {

     if (s.charAt(i) == c) {

       count++;

     }

   }

   

   System.out.printf("%c %s\n", c, s);

   System.out.printf("%d %c%s\n\n",count, c, count==1 ? "":"'s");

 }

 

 public static void main(String[] args) {

   analyzeString('n', "Monday");

   analyzeString('z', "Today is Monday");

   analyzeString('n', "It’s a Sunday day");

   analyzeString('n', "Nobody");

 }

}

Explanation:

I did not add code to prompt the user for input, but rather added the test cases as you provided.

By the way, there is only one 'n' in 'It's a Sunday day'. So the example is wrong there.

Other Questions
express the ratio below in its simplest form.3:12:9 The role of O2 in electron transport In mitochondrial electron transport, what is the direct role of O2 What does a food web, food chain, and energy pyramid show about an ecosystem? Question 2 options: The flow of energy What organisms eat The diversity of an ecosystem (how many different organisms there are) All of these. What happened to the uss maine and what rallying cry came out of it?. I just need help with this pls Find the area of trapezoid ABCD by decomposing it into a rectangle and triangle.A)80 cm^2B)96 cm^2C)104 cm^2 D)112 cm^2 WHAT TIME IS TWENTY FIVE TO EIGHTT??? The length and the breadth of a rectangle are 40 m and 30 m respectively. If its perimeter = perimeter of a square. Find the side of the square Identify the congruent corresponding parts. Which number is not in scientific notation? (1 point)0.2 10^33 10^281.03 10^21.5 10^6 Read the following passage: The baby whale was less than half the size of its mother. It bobbed along, never leaving her side. I tried to get a good picture of it before the pod passed us by, and luckily it surfaced just as it was passing by. I got a great shot of the baby whale and couldn't wait to show my mom, but I didn't want to miss the rest of the whales. I put down my camera and watched them swim away until they were out of sight. Select the sentence that explains why the baby whale "bobbed along" beside its mother. A. It had to com up for air, and went back don underwater. B. It was slow so it needed to move up and down for air. C. It when up and down in the water to look for its mother A 9-pack of plastic cups costs $4.51. What is the unit price, rounded to the nearest cent?$ ___ per cup Open the graphing tool to see the data on a scatter plot, where the month is the independent variable and the principal balance is the dependent variable.1. Select Relationship.2. Select Linear.3. Check the Best fit box.4. Observe the best fit function calculated and provided underneath the graph.What is the best fit function for the data? A prism is completely filled with 72 cubes that have edge lengths of 1/2 in.What is the volume of the prism?Enter your answer in the box.in All of the following were causes of World War II, EXCLUDING . . . Question 10 options:Aggressive expansion of Germany, Italy and JapanThe policy of appeasementThe Russian RevolutionThe failure of the League of Nations to prevent war from breaking out Explain how the idea of Manifest Destiny was used to justify westward expansion. (3-5 sentences) redaccion de la tala de arboleshagan un resumen o algo pero lo nesesito please help find the point of intersection (ordered pair)x + 2y=3 2x - 4y = -20 100 percent of your income after you re tire will probably come from social securityand the companies that employed you.Is it true or false? Three sisters, whose average age is 10, all have different ages. When they get together in pairs, the average ages of two such pairs are 11 and 12. What is the age of the eldest sister?