if statement - Java Program in course not working -
i have been following java course http://www.programmingbydoing.com , stuck on 1 of assignments code here: http://pastebin.com/raw.php?i=si49cbn9
public static void main( string[] args ) { scanner keyboard = new scanner ( system.in ); int age; string name; system.out.println( "what name" ); name = keyboard.next(); system.out.println( "so " + name + "how old you? ") age = keyboard.nextint(); if ( age < 16 ); { system.out.println( "you cant drive"); } else ( age <= 17 ); { system.out.println( "you can drive, not vote." ); } else ( age <= 24 ); { system.out.println( "you can vote not rent car" ); } else if { system.out.println( "you can pretty anything" ); } }
the assignments is: using if statements, else if, , else statements, make program displays different message depending on age given.
age message less 16 "you can't drive." 16 17 "you can drive not vote." 18 24 "you can vote not rent car." 25 or older "you can pretty anything."
note unlike original "how old you" assignment, program must display 1 message given age , not multiple messages.
multiple issues
if ( age < 16 ) { //see no ; here. ; makes end of statement system.out.println( "you cant drive"); } else if( age <= 17 ) { //something else }
Comments
Post a Comment