hi...
i got problem with my code.
i unable to display the largest and smallest integer in range of 1 to 100...
This is the title.
Write a program that reads a list of positive numbers < 100 and displays the largest and the smallest. A 0 (the number zero) should terminate the list. Do not use an array to answer this question. There is at least one number before the 0.
this my code.
[CODE]public class Integer3 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code appli public static void main(String [] args) { int min = 0; int max = 0; int integer = 0; max=min=integer; Scanner keyboard = new Scanner(System.in); System.out.print("Please enter a positive integer or 0 to terminate: "); integer = keyboard.nextInt(); while(integer != 0) { if(integer >max ) { max = integer; } if(integer < min ) { min =integer; } if (integer < 1 || integer >100) { System.out.println("Please enter again a positive integer"); integer = keyboard.nextInt() } } System.out.println("Smaller integer: " + min);//display the smallest integer System.out.println("Largest integer: "+max);//display the largest } } }