what is wrong with my code, the output is always in an endless loop and my application keeps on closing due to this.
import java.util.Random;
public class Whilewhile{
public static void main(String []args){
Random number = new Random();
float x = 1;
float largest = x, smallest = x;
while ((x > 0)&&(x < 10)){
x = number.nextFloat(10);
System.out.println(x);
if (x > largest) {
largest = x;
}
if (x < smallest) {
smallest = x;
}
}
System.out.println("Largest number: " + largest);
System.out.println("Smallest number: " + smallest);
}
}
Aucun commentaire:
Enregistrer un commentaire