March 5th, 2013, 06:14 PM

Newbie help
hello Im new java and I am taking a class and am stuck on this example:
write a program to print out values of square root of all integers divisible by 5 between 5 and 100.
I dont understand how to check each number between 5 and 100 including those two to see if they are divisible by 5 and then im supposed to find the root for the numbers that were divisible by 5. Im very confused and not sure what to do any help would be appreciated
March 5th, 2013, 07:08 PM

what i have so far
what i have so far
public class RootInt {
public static void main(String args[]) {
for(int i=5; i<=100; i++){
for(int j=5; i%j==0; j++){
System.out.println(i);
}
}
}}
March 5th, 2013, 07:16 PM

is this right?
I think i figured it out does this look right???
public class RootInt {
public static void main(String args[]) {
for(int i=5; i<=100; i++){
for(int j=5; i%j==0; j++){
System.out.println(Math.sqrt(i));
}
}
}}
March 5th, 2013, 07:23 PM

not sure this is right
when i run this program with the sqrt function it lists 30, and 90 twice anyreasons why?
March 5th, 2013, 07:30 PM

Code:
public class Root {
public Root() {
// TODO Autogenerated constructor stub
for(int i=5;i<=100;i+=5){
System.out.println(Math.sqrt(i));
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Autogenerated method stub
new Root();
}
}
March 5th, 2013, 07:40 PM

thanks for that this is what i got now:
public class RootInt {
public static void main(String args[]) {
for(int i=5;i<=100;i+=5){
System.out.println("The values of square root for " + i + ": "+ Math.sqrt(i));
}
}
}
March 5th, 2013, 07:46 PM

TRY
public class RootInt {
public static void main(String args[]) {
for(int i=5;i<=100;i+=5)System.out.println("The values of square root for " + i + ": "+ Math.sqrt(i));
}
}