mardi 20 novembre 2018

If else statement with 4 outcomes but only 2 seems to work

So I'm working on my first project on programming at my new study. Never tried programming anything before. I want to make it able to choose between 4 different outcomes and a default function but it only seems to be able to choose between the if statement and the second else if. What have I done wrong?

private void userStandby () {                                                             


System.out.println("What do you want to set your membershipstatus to");                       
System.out.println("1) Active \n2) Standby");                                              
int newchange = input.nextInt();                                                          


 ((Medlem) currentUser).setStatus(newchange);                                             

 if (((Medlem) currentUser).getStatus() == 1 && newchange == 1) {                         
     System.out.println("Your membership is already active");                             

 }                                                                                        
  else if (((Medlem) currentUser).getStatus() == 1 && newchange == 2)  {                  
  System.out.println("Your membership is now on standby");                              
     }                                                                                    

  else if (((Medlem) currentUser).getStatus() == 2 && newchange == 2) {                   
    System.out.println("Your membership is already on standby");                      
  }                                                                                       

 else if (((Medlem) currentUser).getStatus() == 2 && newchange == 1) {                    

     System.out.println("Your membership is now active");                                   
 }                                                                                        

 else                                                                                     
    System.out.println("Please write 1 or 2");                                  

 userStandby();                                                                           

    }                                                                                     

Aucun commentaire:

Enregistrer un commentaire