This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
import java.io* ; public class OddEven { public static void main( String args[] ) { BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)) ; String inputData ; try { String inputData = inputReader.readLine(); } catch(IOException e) { System.out.println("Error reading keyboard input") ; float f ; try{ f = Float.parseFloat(inputData) ; } catch(NumberFormatException e) { System.out.println("Invalid value. Did you enter a number?") ; } } { if (inputData % 2 == 0) System.out.println( "Even" ); else if (inputData % 2 != 0) System.out.println( "Odd" ); } } }
OddEven.java:2: ';' expected import java.io*; ^ 1 error
import java.io.*; public class OddEven { public static void main( String args[] ) { BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); String inputData = ""; float f = 0.0f; try { inputData = inputReader.readLine(); } catch(IOException e) { System.out.println("Error reading keyboard input"); return; } try { f = Float.parseFloat(inputData); } catch(NumberFormatException e) { System.out.println("Invalid value. Did you enter a number?"); return; } if (f % 2 == 0) System.out.println( "Even" ); else if (f % 2 != 0) System.out.println( "Odd" ); } }
When I try to compile it in the Terminal, there is an error
Could someone help me out here and tell me what to change? Keep in mind that I am very new to programming (literally started yesterday)