I\'m trying to get the highest and lowest numbers entered by the user. The code below seems to be mostly working but I can\'t seem to get the right number for the lowest val
import java.io.*;
public class jem3{
public static void main(String []args){
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
int high=0;
int lowest=0;
int num=0;
boolean test = true;
System.out.println("Enter number");
for(int a=0;a<10;a++)
{
try
{
num=Integer.parseInt(dataIn.readLine());
}
catch(IOException e)
{
System.out.println("error");
}
if(num>high)
{
high=num;
}
//add an initial value to 'lowest'
if (test)
lowest = num;
test = false;
if(num < lowest)
{
lowest = num;
}
}
System.out.println("highest is:"+ high);
System.out.println("lowest is: "+ lowest);
}
}