java - Looping user information -


im running small error im bit confused on. have fixed many of problems ive had cannot figure out how running. error?small error

{    int y = 0;    int n = 0;      public static void main( string[] args ) throws java.lang.exception    {        scanner reader = new scanner(system.in);      system.out.println("would play game? [y] yes, [n] no");      int playgame = reader.nextint();      if ( playgame == 'y' )      {  	system.out.println("good lets continue!");      }      else      {  	system.out.println("have day!");      }      system.out.println("would play pick 3, pick 4 or pick 5? [3] pick 3,     [4] pick 4, [5] pick 5");      int pickgame = reader.nextint();      if ( pickgame == '3' )      {  	system.out.println("you have chosen pick 3 ");      }     }  }

i highly recommend reading more on java input , output methods reading input user inexperienced in this. looking @ code seems have general idea of how done. you'd use conditional statement/loop check user input , make decision based on that.

i'd suggest reading on java decision making , more directly the if-else statement.

your goal learn how use conditional statement evaluate user's input , perform action based on it.

a simple example be

public class {     public static void main( string[] args )     {         scanner scan = new scanner(system.in);         string s = scan.next();         int = scan.nextint(); //to parse text int         ...     } } 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -