Java Reference
In-Depth Information
that returns the number of items of the current purchase. Remember to reset
the count at the end of the purchase.
΢΢Exercise P4.3. Implement a class IceCreamCone with methods
getSurfaceArea() and getVolume() . In the constructor, supply
the height and radius of the cone. Be careful when looking up the formula
for the surface areaȌyou should only include the outside area along the
side of the cone since the cone has an opening on the top to hold the ice
cream.
΢΢Exercise P4.4. Write a program that prompts the user for two numbers,
then prints
ȗ 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 Pair
{
/**
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
174
175
Search WWH ::




Custom Search