hasnextint in java code example
Example 1: scanner check if int
boolean isAnInt = scanner.hasNextInt();
Example 2: hasnext in java
import java.util.*;
import java.util.regex.Pattern;
public class ScannerDemo {
public static void main(String[] args) {
String s = "Hello World! 3 + 3.0 = 6";
Scanner scanner = new Scanner(s);
System.out.println("" + scanner.hasNext());
System.out.println("" + scanner.nextLine());
System.out.println("" + scanner.hasNext());
scanner.close();
}
}
Example 3: floor() in c++
floor(x):This function in C++ returns the smallest possible integer value which is smaller
than or equal to the given argument.
Input : 2.5 ,-2.1 ,2.9
Output : 2 ,-3, 2