Here's the error that I'm getting for a simple program that gets a pound value and returns it as Kg:
Enter a pound value:
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.nextDouble(Scanner.java:2413)
at returnType2.main(returnType2.java:12)
And here's the code:
import java.util.Scanner;
public static void main (String args[]) throws Exception
{
Scanner myScanner = new Scanner(System.in);
double pound, kg;
System.out.println("Enter a pound value:");
pound = myScanner.nextDouble();
kg = convertToKg (pound);
System.out.println("In kilograms:");
System.out.println(kg);
}
public static double convertToKg (double num)
{
double kg;
kg = (num * 2.2);
return kg;
}