R
Radith
public class Random {
public static void main(String[] args) {
double i = Math.random() * 100;
int j = 0;
while ((int) i == 90) {
i = Math.random() * 100;
j++;
}
System.out.println("It took " + j " batches to produce the double 90
using a cast");
}
}
THERE SEEMS TO BE THREE ERRORS WITH THE ABOVE CODE; CAN YOU PLS. HELP:
* There's an error in System.out.println
* j doesn't increment
* calculation / while statement seems to be incorrect. IS the cast a
prob. here?
Sorry this maybe simple stuff but I'm still a begginer.
All help Appreciated. Thanks in advance.
Cheers
public static void main(String[] args) {
double i = Math.random() * 100;
int j = 0;
while ((int) i == 90) {
i = Math.random() * 100;
j++;
}
System.out.println("It took " + j " batches to produce the double 90
using a cast");
}
}
THERE SEEMS TO BE THREE ERRORS WITH THE ABOVE CODE; CAN YOU PLS. HELP:
* There's an error in System.out.println
* j doesn't increment
* calculation / while statement seems to be incorrect. IS the cast a
prob. here?
Sorry this maybe simple stuff but I'm still a begginer.
All help Appreciated. Thanks in advance.
Cheers