1. Add the following method to the Point class:
public double distance(Point other)
Returns the distance between the current Point object and the given other Point object. The distance between two points is equal to the square root of the sum of the squares of the differences of their x- and y-coordinates. In other words, the distance between two points (x1, y1) and (x2, y2) can be expressed as the square root of (x2 - x1)2 + (y2 - y1)2. Two points with the same (x, y) coordinates should return a distance of 0.0.
public class Point {
int x;
int y;
// your code goes here
}
2. Create a class called Name that represents a person's name. The class should have fields named firstName representing the person's first name, lastName representing their last name, and middleInitial representing their middle initial (a single character). Your class should contain only fields for now.
3. Add two new methods to the Name class:
public String getNormalOrder()
Returns the person's name in normal order, with the first name followed by the middle initial and last name. For example, if the first name is "John", the middle initial is 'Q', and the last name is "Public", this method returns "John Q. Public".
public String getReverseOrder()
Returns the person's name in reverse order, with the last name preceding the first name and middle initial. For example, if the first name is "John", the middle initial is 'Q', and the last name is "Public", this method returns "Public, John Q.".
4. Add the following method to the Point class:
public int quadrant()
Returns which quadrant of the x/y plane this Point object falls in. Quadrant 1 contains all points whose x and y values are both positive. Quadrant 2 contains all points with negative x but positive y. Quadrant 3 contains all points with negative x and y values. Quadrant 4 contains all points with positive x but negative y. If the point lies directly on the x and/or y axis, return 0.
public class Point {
private int x;
private int y;

// your code goes here
}

Answers

Answer 1

Answer:

Explanation:

The following code is written in Java and creates all of the methods that were requested in the question. There is no main method in any of these classes so they will have to be called from the main method and call one of the objects created method for the code to be tested. (I have tested it and it is working perfectly.)

class Point {

   private int x, y;

   public void Point(int x, int y) {

       this.x = x;

       this.y = y;

   }

   public double distance (Point other) {

      double distance = Math.sqrt(Math.pow((other.x - this.x), 2) + Math.pow((other.y - this.y), 2));

      return distance;

   }

   

   public int quadrant() {

       if (this.x > 0 && this.y > 0) {

           return 1;

       } else if (this.x < 0 && this.y > 0) {

           return 2;

       } else if (this.x < 0 && this.y < 0) {

           return 3;

       } else if (this.x > 0 && this.y < 0) {

           return 4;

       } else {

           return 0;

       }

   }

}

class Name {

   String firstName, lastName;

   char middleInitial;

   

   public String getNormalOrder() {

       String fullName = firstName + " " + middleInitial + " " + lastName;

       return fullName;

   }

   

   public String getReverseOrder() {

       String fullName = lastName + ", " + firstName + " " + middleInitial;

       return fullName;

   }

}


Related Questions

. Which of these perform real-world activities such as eating, sleeping, walking, and running in virtual worlds?

Answers

Answer:

all

Explanation:

Answer:

avatars

Explanation: I just took the test

See the lseek_example.c file. Modify the lseek_example.c, such that it reads from an input file (named "start.txt") and will print to an output file (named "end.txt") every (1+3*i)th character, starting from the 1st character in the input file. In other words, it will print the 1st character, then skip 2 characters and print the 4th one, then skip 2 characters and print the 7th one, and so on.
For instance, for input file:
ABCDEFGHIJKLM
It will output:
ADGJM
Iseek_example.c file contant:
// C program to read nth byte of a file and
// copy it to another file using lseek
#include
#include
#include
#include
void func(char arr[], int n)
{
// Open the file for READ only.
int f_read = open("start.txt", O_RDONLY);
// Open the file for WRITE and READ only.
int f_write = open("end.txt", O_WRONLY);
int count = 0;
while (read(f_read, arr, 1))
{
// to write the 1st byte of the input file in
// the output file
if (count < n)
{
// SEEK_CUR specifies that
// the offset provided is relative to the
// current file position
lseek (f_read, n, SEEK_CUR);
write (f_write, arr, 1);
count = n;
}
// After the nth byte (now taking the alternate
// nth byte)
else
{
count = (2*n);
lseek(f_read, count, SEEK_CUR);
write(f_write, arr, 1);
}
}
close(f_write);
close(f_read);
}
// Driver code
int main()
{
char arr[100];
int n;
n = 5;
// Calling for the function
func(arr, n);
return 0;
}

Answers

Answer:

See the lseek_example.c file. Modify the lseek_example.c, such that it reads from an input file (named "start.txt") and will print to an output file (named "end.txt") every (1+3*i)th character, starting from the 1st character in the input file. In other words, it will print the 1st character, then skip 2 characters and print the 4th one, then skip 2 characters and print the 7th one, and so on.

For instance, for input file:

ABCDEFGHIJKLM

It will output:

ADGJM

Iseek_example.c file contant:

// C program to read nth byte of a file and

// copy it to another file using lseek

#include

#include

#include

#include

void func(char arr[], int n)

{

// Open the file for READ only.

int f_read = open("start.txt", O_RDONLY);

// Open the file for WRITE and READ only.

int f_write = open("end.txt", O_WRONLY);

int count = 0;

while (read(f_read, arr, 1))

{

// to write the 1st byte of the input file in

// the output file

if (count < n)

{

// SEEK_CUR specifies that

// the offset provided is relative to the

// current file position

lseek (f_read, n, SEEK_CUR);

write (f_write, arr, 1);

count = n;

}

// After the nth byte (now taking the alternate

// nth byte)

else

{

count = (2*n);

lseek(f_read, count, SEEK_CUR);

write(f_write, arr, 1);

}

}

close(f_write);

close(f_read);

}

// Driver code

int main()

{

char arr[100];

int n;

n = 5;

// Calling for the function

func(arr, n);

return 0;

}

Explanation:

Libby’s keyboard is not working properly, but she wants to select options and commands from the screen itself. Which peripheral device should she use?
A.
voice recognition
B.
microphone
C.
mouse
D.
compact disk

Answers

C. mouse is the answer

NO LINKS OR I WILL DELETE YOUR FORTNITE ACCOUNT
What can you do with the free version of the splice editor

Answers

Answer:

can i have ur fortnite account if u hav one and dont use it :) i only say that cuz u mentioned fortnite

Explanation:

with the free version you can add effects (cheap effects) cut the video, crop some parts. and posting leaves a watermark until u buy money

Answer:

It has a 7 day free trial while your using the free version

Explanation:

how to learn python ?

Answers

Answer:

See below.

Explanation:

To learn python programming language, first, you have to know the basic. Surely, you may recognize this function namely print()

print(“Hello, World!”) — output as Hello, World!

First, start with familiarizing yourself with basic function such as print. Then step up with arithmetic and declare or assign variable then list.

Here are example of functions:

1.) print(argument) — If argument is a string (word-typed), make sure to use “” or ‘’ or else it’ll output an error and say the argument is not defined.

print(“Hi, Brainly”) will output Hi, Brainly

print(2+3) will output 5

Numerical data or numbers do not necessarily require “ “ or ‘ ‘

print(3+3) will output 6 but print(“3+3”) will output 3+3 which is now a string.

2.) type(argument) - this tells you which data/argument it is. There are

< class ‘str’ > which is string, meaning it contains “ “ or ‘ ‘< class ‘int’ > which is integer< class ‘float’ > which is decimal (20.0 is also considered as float, basically anything that contains decimal is all float type)< class ‘list’ > which is a list. List is something that contains elements within square brackets [ ]

etc.

Make sure you also do print(type(argument)) as well so it will print out the output.

3.) Arithmetic

+ is addition

Ex. print(1+3) will output 4

   2. - is subtraction

Ex. print(5-4) will output 1

   3. * is multiply

Ex. print(4*5) will output 20

   4. ** is exponent

Ex. print(5**2) will output 25

   5. / is division

Ex. print(6/3) will output 2 — sometimes will output the float type 2.0

   6. % is modulo or remainder

Ex. print(7%2) will output 1

4.) Variables

To assign a variable, use =

An example is:

x = 2

y = 5

print(x+y) will output 7

print(type(x)) will output the < class ‘int’ >

These are examples of what you’ll learn in basic of python - remember, programming depends on experience and always focus on it. Keep practicing and searching will improve your skill at python.

User ideas for ro blox? I prefer no numbers or underscores.

Answers

do what the other person said

Other Questions
Setting and achieving goals is essential to success.a. Trueb. False Helppppppppppppppppppppppppppppppasap Alright fam, help me out here with these angles thanks! I -9I = ____HELP HELP ME ME ASAP PLEASE What percent of 54 is 28? 3) Imaginewe have two candidates with real credentials Type of sentence: discuss two reasons why people find transition between school and university PLEASE HELP ME WITH ALL OF THESE!! I'LL GIVE BRAINLIEST I SWEAR!! Please help ill give BRAINLIEST. This is geometry 1.What important position was Andrew Young appointed to during the Carter administration?A.Attorney GeneralB.Ambassador to the United Nations C.Foreign secretary of war D.Secretary of State2.Which statement best describes the importance immigrant communities have on Georgia's economic growth? A.Immigrants communities are important economically because they bring religious diversity to communities.B.Immigrant communities are important economically because they encourage the growth of multilingual programs at schools.C.Immigrant communities are important economically because they assist in many jobs and businesses strengthening the workforce. D.Immigrant communities are important economically because they increase the awareness of racial discrimiination.3.Which statement best describes the impact immigrant populations have on Georgias communities?A.Georgias communities are minimally impacted by immigrant populations.B.Georgias communities have seen an increase in the number of restaurants, churches, and various businesses owned and operated by immigrants. C.Georgias communities have seen a decrease in the ethnic diversity of many of its major cities.D.Georgias communities have seen an influx of immigrants from only Latin American countries. 5.What was the significance of Maynard Jackson serving as mayor of Atlanta?A.He was the first foreign-born mayor of AtlantaB.He was the first non-college educated mayor of AtlantaC.He was the first Republican mayor since ReconstructionD.He was the first black mayor of a major Southern city6.Which of the following provide the main source of growth to our economy by risking their own time and money to build new products and businesses?A.Business ManagerB.CapitalistC.EntrepreneurD.Property Owner What position did Andrew Young occupy as the first African-American since Reconstruction?A.Serve as a Congressmen from GeorgiaB.Serve as mayor of a major Southern cityC.Be elected as governor of a Southern stateD.Be elected to the school board of Atlanta Public Schools11.How did Maynard Jackson and Andrew Young help Atlanta develop SOCIALLY?A.They both pushed for integration of the public schools.B.They both held weekly meet the mayor gatherings at City Hall.C.They both helped minority-owned businesses get contracts.D.They both insisted on strong policing to reduce the crime rate.Why was the expansion of the Port of Savannah economically important to Georgia?A.It helped Georgia's fishing industry grow and prosper.B.It helped bring more international tourists to Savannah.C.It helped Savannah become a center of film production.D.It helped Georgia increase its role in international trade. Which article or group of articles addresses the protection of rights?Article IArticle IIArticles IIIVI and IXArticles VIIVIII A student was explaining to the class about freshwater and the importance that it has to everyones life. What is NOT true about freshwater biomes? A. Freshwater biomes are found all over the world B. There is a wide variety of climates that have freshwater biomes C. There are different types of bodies of freshwater biomes D. They have more than 5% salt content which graph shows the solution to the system of equations?y =-2x+1 and y =-3/2 Describe the processes for precertification using the paper method. What does the medical assistant need to do? The total of your bill at the restaurant is $42.50.You want to leave a 10%tip. What is the amount of money you would leave for the tip. Brainly If you know how to do this please help me. Please answer asapno work needed :) Read the sentence.Sayeed Johnson, whois running for mayor, will be speaking at the city library tonight.Which terms describe the underlined portionof the sentence? Select twooptions.O appositiveclausenonrestrictiveO phraseO restrictive The Adams family bought a small piece of land in the hill country. The plot is in the shape of a rectangle and measures about 50 yards by 41 yards. What is the area of the plot? Given the two equations:y + x = 5-2x = -10) Draw the graphs of both equations on the same pair of axes by using a scale of 1cm torepresent 1 unit on both axes.Use your graph to determine the point of intersection.