Hello, I am trying to write a program to solve a simultaneous equation. It runs through all the possibilites for x, and if any of them forfil the conditions of y, then it is displayed. My problem is that i don't know how to make it so that only positive integers are displayed. What I have done was change a double value integer, and then display that, but all it does it cut of the decimals, not give me all the possibles for x and y that are whole numbers without being rounded.
Here is my code
[CODE]
class Maths {
public static void main (String[] args) {
for (int y = 10; y <= 92; y++){
double a = Math.sqrt((y*y) +180);
int x = (int)a;
System.out.prin tln(x + " " + y + " ");
}
}
}
[CODE]
Thanks to anyone who helps
Here is my code
[CODE]
class Maths {
public static void main (String[] args) {
for (int y = 10; y <= 92; y++){
double a = Math.sqrt((y*y) +180);
int x = (int)a;
System.out.prin tln(x + " " + y + " ");
}
}
}
[CODE]
Thanks to anyone who helps
Comment