- #1
squelchy451
- 25
- 0
Hi
I wanted to make a program that would check if a number if it was an integer or not in Java. here's the source code:
import static java.lang.Math.*;
public class gcd {
public static void main(String [] args) {
double a = 1;
double b =1;
double c = 1;
int counter = 1;
if ( counter < 10) {
a=a+1;
b =10 * Math.sqrt((a * a - 42)/3);
c = b%10;
System.out.println("a: " + a);
System.out.println("b: " + b);
System.out.println("c: " + c);
System.out.println("counter: " + counter);
if(c == 0) {
System.out.println(b);
counter = counter + 1;
}
}
}
}
For the output I get
a: 2.0
b: NaN
c: NaN
counter:1
So the loop doesn't work and i get weird NaN values for b and c...i run it by changing the directory on command prompt and typing in "java gcd"
I used to use JCreator in my Java class...any recommended free programs for java?
Thanks!
I wanted to make a program that would check if a number if it was an integer or not in Java. here's the source code:
import static java.lang.Math.*;
public class gcd {
public static void main(String [] args) {
double a = 1;
double b =1;
double c = 1;
int counter = 1;
if ( counter < 10) {
a=a+1;
b =10 * Math.sqrt((a * a - 42)/3);
c = b%10;
System.out.println("a: " + a);
System.out.println("b: " + b);
System.out.println("c: " + c);
System.out.println("counter: " + counter);
if(c == 0) {
System.out.println(b);
counter = counter + 1;
}
}
}
}
For the output I get
a: 2.0
b: NaN
c: NaN
counter:1
So the loop doesn't work and i get weird NaN values for b and c...i run it by changing the directory on command prompt and typing in "java gcd"
I used to use JCreator in my Java class...any recommended free programs for java?
Thanks!