Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
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() {. . .}
...
}

INSTRUCTIONS
The PairTest.java 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
Updated 9-Oct-12 1:07am
v3

1 solution

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.
 
Share this answer
 
Comments
[no name] 8-Oct-12 22:22pm    
Excuse me? Never learned any manners did you?
[no name] 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"
fjdiewornncalwe 9-Oct-12 9:49am    
Don't feel sad, Wes. Some of us consider you welcome here. :)
[no name] 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 @ oracle.com.

We are professionals, you would have to pay us to write your code.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900