Java: Why Doesn't My While Statement Work With My Case 2? -


i trying create simple program outputs lyrics of song when specified number inputted. problem second case not output, outputs first case. when try output second case, still outputs first. regardless if make 2 while statement or not, still happens. can me fix code?

here is:

import java.util.scanner; public class lyrics { public static void main (string args[]){         scanner input = new scanner (system.in);         int one, two, uone, utwo;         1 = 1;         2 = 2;         system.out.println("welcome lyrics finder!");         system.out.println("press number beside song see lyrics!");         system.out.println("1) thank memories - fall out boy");         system.out.println("2) take me church - hozier");         uone = input.nextint();         utwo = input.nextint();         switch (one){         case 1:             //code goes here option 1             system.out.println("");             system.out.println("thank memories - fall out boy lyrics");             system.out.println("         ==          ");             system.out.println("i'm gonna make bend , break");             system.out.println("say prayer let times roll");             system.out.println("in case god doesn't show");             system.out.println("(let times roll, let times roll)");             system.out.println("and want these words make things right");             system.out.println("but it's wrongs make words come life");             system.out.println("who think is?");             system.out.println("who think is?");             system.out.println("better put fingers keys");             //continue song here             break;         case 2:             //retype code reset             system.out.println("");             system.out.println("take me church - hozier");             system.out.println("          ==             ");             system.out.println("my lover's got humour, she's giggle @ funeral");             system.out.println("knows everybody's disapproval, should've worshipped sooner");             system.out.println("if heavens ever did speak, she's last true mouthpiece");             system.out.println("every sunday's getting more bleak, fresh poison each week");             system.out.println("we born sick heard them it");             system.out.println("my church offers no absolutes, tells me worship in bedroom");             break;   }         while (uone == one){             system.out.println("");             system.out.println("<-=lyrics above=->");             system.out.println("<-=options=->");             system.out.println("press number beside song see lyrics!");             system.out.println("1) thank memories - fall out boy");             system.out.println("2) take me church - hozier");              uone = input.nextint();             utwo = input.nextint();             switch (one){             case 1:                 //code goes here option 1                 system.out.println("");                 system.out.println("thank memories - fall out boy lyrics");                 system.out.println("         ==          ");                 system.out.println("i'm gonna make bend , break");                 system.out.println("say prayer let times roll");                 system.out.println("in case god doesn't show");                 system.out.println("(let times roll, let times roll)");                 system.out.println("and want these words make things right");                 system.out.println("but it's wrongs make words come life");                 system.out.println("who think is?");                 system.out.println("who think is?");                 system.out.println("better put fingers keys");                 //continue song here                 break;             case 2:                 //retype code reset                 system.out.println("");                 system.out.println("take me church - hozier");                 system.out.println("          ==             ");                 system.out.println("my lover's got humour, she's giggle @ funeral");                 system.out.println("knows everybody's disapproval, should've worshipped sooner");                 system.out.println("if heavens ever did speak, she's last true mouthpiece");                 system.out.println("every sunday's getting more bleak, fresh poison each week");                 system.out.println("we born sick heard them it");                 system.out.println("my church offers no absolutes, tells me worship in bedroom");                 break;         }  } } } 

when user types number one, should outputted:

system.out.println("");                 system.out.println("thank memories - fall out boy lyrics");                 system.out.println("         ==          ");                 system.out.println("i'm gonna make bend , break");                 system.out.println("say prayer let times roll");                 system.out.println("in case god doesn't show");                 system.out.println("(let times roll, let times roll)");                 system.out.println("and want these words make things right");                 system.out.println("but it's wrongs make words come life");                 system.out.println("who think is?");                 system.out.println("who think is?");                 system.out.println("better put fingers keys");                 //continue song here                 break; while (uone == one){                 system.out.println("");                 system.out.println("<-=lyrics above=->");                 system.out.println("<-=options=->");                 system.out.println("press number beside song see lyrics!");                 system.out.println("1) thank memories - fall out boy");                 system.out.println("2) take me church - hozier"); 

when user types number 2, should outputted:

system.out.println("");                 system.out.println("take me church - hozier");                 system.out.println("          ==             ");                 system.out.println("my lover's got humour, she's giggle @ funeral");                 system.out.println("knows everybody's disapproval, should've worshipped sooner");                 system.out.println("if heavens ever did speak, she's last true mouthpiece");                 system.out.println("every sunday's getting more bleak, fresh poison each week");                 system.out.println("we born sick heard them it");                 system.out.println("my church offers no absolutes, tells me worship in bedroom");                 break; while (uone == one){                 system.out.println("");                 system.out.println("<-=lyrics above=->");                 system.out.println("<-=options=->");                 system.out.println("press number beside song see lyrics!");                 system.out.println("1) thank memories - fall out boy");                 system.out.println("2) take me church - hozier"); 

please note new coding, please try explain best can. if not, still may able understand, regardless, please briefly explain solution.

change

    uone = input.nextint();     utwo = input.nextint();     switch (one){ 

to

    int choice = input.nextint();      switch (choice) 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -