Exception in thread “main” java.util.NoSuchElementException at java.util.Scanner.throwFor(Scanner.java:862) at java.util.Scanner.next(Scanner.java:1485) at java.util.Scanner.nextInt(Scanner.java:2117) at java.util.Scanner.nextInt(Scanner.java:2076) at Main.main(Main.java:13)
Why i am getting this error even after taking input?
Hey @Nitya_Somani
logic is fine
just use Single Scanner
Correct code :
import java.util.*;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner scan1= new Scanner(System.in);
int fmin=scan1.nextInt();
// Scanner scan2=new Scanner(System.in);
int fmax=scan1.nextInt();
// Scanner scan3=new Scanner(System.in);
int fstep=scan1.nextInt();
int fcurrent = fmin;
while(fcurrent <=fmax)
{
int celsius = (int)((5.0/9)*(fcurrent-32));
System.out.println(fcurrent +"\t"+ celsius);
fcurrent =fcurrent+fstep;
}
}
}