java - Enrollment System -


i trying make project out of had learn online.

public static void main(string[]args){      int balance, payment;       balance = 11310;      string new1 = "new";      string old = "old";      string partial = "partial";      string full = "full";      string no = "no";      string yes = "yes";      string first = "first year second sem";      string second = "second year first sem";      string third = "second year second sem";      system.out.print("\nenter name: ");      scanner st = new scanner(system.in);      string name = st.nextline();      system.out.print("\nold student or new student: ");      string student = st.nextline();      if(student.equalsignorecase(new1)){          system.out.print("\ngreetings, "+name);          system.out.print("\nplease fill out our registration form.");          system.out.print("\nthank you!");      try {       if(desktop.isdesktopsupported()) {          desktop.getdesktop().open(new file("c:\\users\\toshiba-1\\desktop\\regform1styr.2ndsem - copy.docx"));       }      }       catch (ioexception ioe) {       ioe.printstacktrace();      }      return;      }       system.out.print("\ngreetings, "+name);      system.out.print("\nwould want enroll new semester? ");      string enroll = st.nextline();      if(enroll.equalsignorecase(no))     {      system.out.print("\nthank you!");       return;     }      if(enroll.equalsignorecase(yes))     {      }      system.out.print("\nwhich semester? ");      string semester = st.nextline();      if(semester.equalsignorecase(first)) // error started here.     {     }      else if(semester.equalsignorecase(second))     {     }      else if(semester.equalsignorecase(third))     {     }      else     {      system.out.print("\nplease choose semester.");     }      system.out.print("\nthe enrollment fee semester is: "+ balance);      system.out.print("\nchoose payment term(partial/full): ");      string term = st.nextline();      if(term.equalsignorecase(partial))      {          system.out.print("\nhow pay semester: ");          scanner in = new scanner(system.in);          payment = in.nextint();           balance = balance - payment;          system.out.print("\nyour balance is: sr"+ balance);          if(balance > payment){              system.out.print("\nyou have remaining balance of: sr" + balance);          }else if(balance == payment){              system.out.print("\nyou paid");          }       }    } } 

i having trouble when user chooses on 3 string. alternatively tried set of codes.

    if(semester.equalsignorecase(first))     {      system.out.print("\nplease choose semester.");     }      system.out.print("\nthe enrollment fee semester is: "+ balance);      system.out.print("\nchoose payment term(partial/full): ");      string term = st.nextline();      if(term.equalsignorecase(partial))      {          system.out.print("\nhow pay semester: ");          scanner in = new scanner(system.in);          payment = in.nextint();           balance = balance - payment;          system.out.print("\nyour balance is: sr"+ balance);          if(balance > payment){              system.out.print("\nyou have remaining balance of: sr" + balance);          }else if(balance == payment){              system.out.print("\nyou paid");     }      else if(semester.equalsignorecase(second))     {      system.out.print("\nplease choose semester.");     }      system.out.print("\nthe enrollment fee semester is: "+ balance);      system.out.print("\nchoose payment term(partial/full): ");      string term = st.nextline();      if(term.equalsignorecase(partial))      {          system.out.print("\nhow pay semester: ");          scanner in = new scanner(system.in);          payment = in.nextint();           balance = balance - payment;          system.out.print("\nyour balance is: sr"+ balance);          if(balance > payment){              system.out.print("\nyou have remaining balance of: sr" + balance);          }else if(balance == payment){              system.out.print("\nyou paid");     }      else if(semester.equalsignorecase(third))     {      system.out.print("\nplease choose semester.");     }      system.out.print("\nthe enrollment fee semester is: "+ balance);      system.out.print("\nchoose payment term(partial/full): ");      string term = st.nextline();      if(term.equalsignorecase(partial))      {          system.out.print("\nhow pay semester: ");          scanner in = new scanner(system.in);          payment = in.nextint();           balance = balance - payment;          system.out.print("\nyour balance is: sr"+ balance);          if(balance > payment){              system.out.print("\nyou have remaining balance of: sr" + balance);          }else if(balance == payment){              system.out.print("\nyou paid");     }      else     { system.out.print("please choose semester.");  return;       } 

but results keeps on getting mix up. please me.

if want code work, need add loop question:

system.out.print("\nwhich semester? "); // changed code!! while(true){     string semester = st.nextline();     if(semester.equalsignorecase(first)){         break;     }else if(semester.equalsignorecase(second)){         break;     }else if(semester.equalsignorecase(third)){         break;     }else{         system.out.print("\nplease choose semester.");     } } //end of chaged code!! system.out.print("\nthe enrollment fee semester is: "+ balance); 

however bad idea base program flow control on strings yours.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -