java classes and methods
import java.lang.Math;
import java.util.Scanner;
public class HelloWorld {
public static void main(String[] args) {
class ResultNumberShape {
double number;
public boolean isSquare(double number) {
double result = Math.sqrt(number);
return ((result - Math.floor(result)) == 0);
}
}
ResultNumberShape checkNumber = new ResultNumberShape();
System.out.println("Enter any number:");
Scanner scanner = new Scanner(System.in);
double num = scanner.nextDouble();
scanner.close();
if (checkNumber.isSquare(num)) {
System.out.println(num + " is a sqaure number!");
} else {
System.out.println(num + " is not a square!");
}
}
}
Also in Java:
- jtable disable row selection
- log10 in java
- java fx display simple rectangle
- how to count number of words in a string
- java string to int
- java.sql.SQLException: Before start of result set
- java list get first element
- java iterator example
- java script removing first three indexes
- java file path linux
- java print treemap
- java nested for loop
- add two numbers bitwise
- java singleton
- Java app development
- java custom color
- how-to-use-volley-string-request-in-android
- java packages example
- java string format .2f
- labeled for loop in java
- change color of particular row in jtable
- how to break from a loop in java
- take a value from keyboard java
- classes in java