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
Rasek [7]
2 years ago
8

Write a class called Line that represents a line segment between two Points. Your Line objects should have the following methods

: public Line(Point p1, Point p2) Constructs a new line that contains the given two points. public Point getP1() Returns this line's first endpoint. public Point getP2() Returns this line's second endpoint. public String toString() Returns a string representation of this line, such as "[(22, 3), (4, 7)]"
Computers and Technology
1 answer:
mel-nik [20]2 years ago
4 0

Answer:

import java.awt.Point;

public class Line{

private Point point1, point2;

public Line(Point p1, Point p2){

point1 = p1;

point2 = p2;

}

public Point getP1(){

return point1;

}

public Point getP2(){

return point2;

}

public String toString(){

return "[( The " + point1.x + "," + point1.y + "), (" + point2.x + "," + point2.y +")]";

}

public static void main(String args[]){

Line lineObj = new Line(new Point(7,9), new Point(6,2));

System.out.println(lineObj.toString());

}

}

Explanation:

  • Declare the points inside the class Line.
  • Initialize the getters and setters method for the class.
  • Define a toString method that returns the information in a formatted manner.
  • Inside the main method, initialize an object with some values.
  • Display the information by calling the toString method.
You might be interested in
How do airbags prevent injury?
NARA [144]

honestly i think ur answer would be D because it keeps you from flying out of the window

8 0
3 years ago
Suppose we wanted to make change for purchases and wanted to use the least number of coins possible. Here is a greedy algorithm:
love history [14]

Answer:

Explanation:

The following code is a Python function that takes in the amount of change. Then it uses division and the modulo operator to calculate the number of coins that make up the changes, using the greatest coin values first.

import math

def amountOfCoins(change):

   print("Change: " + str(change))

   quarters = math.floor(change / 0.25)

   change = change % 0.25

   dimes = math.floor(change / 0.20)

   change = change % 0.20

   pennies = math.floor(change / 0.01)

   print("Quarters: " + str(quarters) + "\nDimes: " + str(dimes) + "\nPennies: " + str(pennies))

5 0
3 years ago
Describe how implementation of a raid level 2 system would be beneficial to a university payroll system
lisabon 2012 [21]

<span>The RAID level 2 could give high information exchange rates and would be straightforward contrasted with other Raid levels. Be that as it may, it has a high cost and would need a high rate move required with a specific end goal to legitimize this cost.</span>

4 0
3 years ago
Suppose you want to delete an existing file from within word. What would you do?
Oksana_A [137]
Go in to ur files and find the file and delete it
5 0
3 years ago
What process combines data from a list with the content of a document to provide personalized documents?
Andrej [43]
The appropriate answer is d. mail merge. Mail merge uses a database of addresses that are used to create pre-addressed mailing labels that are generally used when sending letters to a very large group. This type of application is used by utility companies or any other organizations that requires mass mailings. Mail merge is found in the Microsoft Word application. Excell spreadsheets can also be used to complete tasks similar to that of mail merge.
8 0
2 years ago
Read 2 more answers
Other questions:
  • Write an algorithm whether the given number is positive negative or zero​
    5·1 answer
  • A keyboard and touch screen are the most common of ________ devices. select one:
    11·1 answer
  • . Identify an emerging crime issue in your community using data available from sources such as local newspapers, online police r
    6·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    6·1 answer
  • In a c program, if you see a variable in main declared: float farray[20]; describe what farray is
    10·1 answer
  • Write a java program to find the perimeter of a triangle with sides measuring 10cm, 14cm and 15 cm.
    8·1 answer
  • If an electric circuit has 30ohms and 10amps. How many volts the battery voltmeter should read?
    10·1 answer
  • Edhesive 2.3 code practice question 1​
    11·1 answer
  • You hide three worksheets in a workbook and need to unhide them. How can you accomplish this?.
    11·1 answer
  • Mario is designing a page layout for a sports magazine, and he decides to add the image of a cyclist. Which principle of page la
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!