Click here to Skip to main content
12,699,883 members (35,425 online)
Rate this:
Please Sign up or sign in to vote.
See more: Java
Write a program that prompts the user for two numbers then points.
The sum
The difference
The product
the average
the distance (absolute value of the difference)
the maximum (the larger of the two)
the minimum (the smaller of the two)

To do so
implement a class
public class fair
Constructs a pair.
@param aFirst the first value of the pair.
@param Asecond the second value of the pair.

public Pair(double aFirst, double aSecond){. . .}
Computes the sum of the values of this pair.
@return the sum of the first and second values
*/ public double getSum() {. . .}

The program should use bullet proof input to prompt and collect the two values for the number pair from the user, create a number pair object using these values, display the initial values and should output the computed 7 listed computed values .

Extra Credit option:
include additional code in the driver (PairTest) that creates a pair with two random double values between 0 and 10 inclusive. Be sure to show the two pair values as well as the computed values. (In other words, the user should be able to confirm that the program is correct using the Random numbers by inspecting the output.)
Posted 8-Oct-12 17:08pm
Updated 9-Oct-12 2:07am
Wes Aday104.2K

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is your homework. You will learn a lot more if you actually try and do it yourself. We can help you if you get stuck with a specific problem but we are not here to do it for you.
Wes Aday 8-Oct-12 22:22pm
Excuse me? Never learned any manners did you?
Wes Aday 8-Oct-12 22:31pm
Just so you cannot delete your comment and deny your abuse, "wes aday please leave this now. Your not welcome here"
Marcus Kramer 9-Oct-12 9:49am
Don't feel sad, Wes. Some of us consider you welcome here. :)
Wes Aday 9-Oct-12 10:02am
Thanks Marcus. I have been so distraught over not being welcome here. I have been waiting for the police to show up though just to find out what they would charge me with. Felony not answering homework? Not doing someone's homework for them in the first degree? Maybe reckless not helping someone cheat?
TorstenH. 9-Oct-12 3:14am
do it yourself. it's as simple.

If you want pre written code check the Java tutorials @

We are professionals, you would have to pay us to write your code.
Wes Aday 9-Oct-12 6:26am
Go ahead and call the police. What do you think that they will charge me with?
Mohibur Rashid 9-Oct-12 7:11am
is this reunion of police? will sting be there?
Wes Aday 9-Oct-12 8:27am
I hope so.... fewer grenades needed... :-)
TorstenH. 9-Oct-12 7:23am
+5 for the "NoEffort" tag - I didn't know we have such one. great!
Wes Aday 9-Oct-12 8:27am
Thanks :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170118.1 | Last Updated 9 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100