Question:
Simple Java Programming Error?
?
2009-09-22 19:36:44 UTC
I'm having some problems during compiling, and may be just doing some stuff wrong in general. This is supposed to be a simple program where the user inputs the number of miles and receives the kilometers as output. Thanks!

import java.util.Scanner;
public class MilesToKilometers {
public static void main(String[] args) {
final double KILOMETERS_PER_MILE = 1.60935;

System.out.println("Enter number of miles: ");
Scanner scan = new Scanner (System.in);
float miles= scan.nextLine();
float kilometers= miles*KILOMETERS_PER_MILE;
System.out.println (miles "miles is equal to" kilometers "kilometers.");

} // method main
} // class MilesToKilometers
Three answers:
Mani S
2009-09-22 19:58:29 UTC
Here's the corrected code - http://pastebin.com/f3c927254



Hope this helps. Let me know if you have any queries. Have fun :)
Martin
2009-09-22 20:19:48 UTC
Hi,Teddy



There are 3 step to repair java programming error



My friend had the same problem with you. I am sure your computer has registry problems.It is very easy to repair java programming error. you just need 3 steps:



1: Download a registry cleaner and install it.

2: Open the registry cleaner and scan you computer for free.

3: Click fix button and you done.



Download the top java programming error repair tool here:http://www.fixerrorfast.com/ttfix-java_programming_error-zz0001
?
2009-09-22 19:54:11 UTC
float miles= scan.nextLine();

needs to be

float miles= scan.nextFloat();


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...