need help with a homework problem and i've been starring at code all day and my brain is fried... any advice or pointers would be greatly appreciated
Description of the Problem
Write a method minimum3 that returns the smallest of three floating-point numbers. Use the Math.min method
to implement minimum3. Incorporate the method into an application that reads three values from the user, determines
the smallest value and displays the result.
// Lab 1: Min.java
// Program finds the minimum of 3 numbers
import java.util.Scanner;
public class Min
{
// find the minimum of three numbers
public void findMinimum()
{
Scanner input = new Scanner( System.in );
double one; // first number
double two; // second number
double three; // third number
System.out.printf( "%s\n %s\n %s\n",
"Type the end-of-file indicator to terminate",
"On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
"On Windows type <ctrl> z then press Enter" );
System.out.print( "Or enter first number: " );
while ( input.hasNext() )
{
one = input.nextDouble();
/* Write code to get the remainder of the inputs and
convert them to double values */
two = input.nextDouble();
three = input.nextDouble();
/* Write code to display the minimum of the three floating-point numbers */
System.out.printf("Minimum is: %f ", minValue);
System.out.printf( "\n%s\n %s\n %s\n",
"Type the end-of-file indicator to terminate",
"On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
"On Windows type <ctrl> z then press Enter" );
System.out.print( "Or enter first number: " );
} // end while
} // end method findMinimum
// determine the smallest of three numbers
/* write the header for the minimum3 method */
public void minimum3()
{
double x;
double y;
double z;
double minValue;
minValue = x;
if (minValue > y)
minValue = y;
if (minValue > z)
minValue = z;
// determine the minimum value
return minValue; /* Write code to compute the minimum of the three numbers
using nested calls to Math.min */
} // end method minimum3
} // end class Min