Code:
import javax.swing.JOptionPane; public class DistanceTraveled { public static void main(String[] args) { int Distance; // D = Distance Traveled int Speed; // S = Speed entered by user int Time; // T = Time entered by user String Input; input = JOptionPane.showInputDialog("What is the speed " + "of the vehicle in miles-per-hour?"); Speed = Integer.parseInt(input); while (Speed < 0) { Input = JOptionPane.showInputDialog("What is the speed " + "of the vehicle in miles-per-hour? " + "*Please enter a POSITIVE number*"); Speed= Integer.parseInt(input); } Input = JOptionPane.showInputDialog("How many hours " + "has the vehicle traveled for?"); Time = Integer.parseInt(Input); while (Time < 1) { input = JOptionPane.showInputDialog("How many hours " + "has the vehicle traveled for? " + "*Please enter a value that is not less than 1*"); Time = Integer.parseInt(Input); } Distance = Speed * Time; // System.out.println("Hour Distance Traveled"); System.out.println("------------------------"); System.out.println(Time + "\t\t" + Distance); for(int Input=1; Input<=Time; Input++) { System.out.println("Hour " + Input + ": " + (Speed*Input) + " miles traveled"); }
reached end of file while parsing
Can anyone tell me what's wrong?
I do not think i have to many brackets.
Comment