Java:为什么';我的While语句不能用于我的案例2吗?
我试图创建一个简单的程序,当输入指定的数字时,输出歌曲的歌词。问题是我的第二个案例不会输出,而只输出第一个案例。当我尝试输出第二种情况时,它仍然输出第一种情况。不管我是否做了两个while语句,这种情况仍然会发生。有人能帮我修改代码吗 这是:Java:为什么';我的While语句不能用于我的案例2吗?,java,Java,我试图创建一个简单的程序,当输入指定的数字时,输出歌曲的歌词。问题是我的第二个案例不会输出,而只输出第一个案例。当我尝试输出第二种情况时,它仍然输出第一种情况。不管我是否做了两个while语句,这种情况仍然会发生。有人能帮我修改代码吗 这是: import java.util.Scanner; public class Lyrics { public static void main (String args[]){ Scanner input = new Scanner (Sy
import java.util.Scanner;
public class Lyrics {
public static void main (String args[]){
Scanner input = new Scanner (System.in);
int one, two, uone, utwo;
one = 1;
two = 2;
System.out.println("Welcome to the Lyrics Finder!");
System.out.println("Press the number beside the song to see the lyrics!");
System.out.println("1) Thank For The Memories - Fall Out Boy");
System.out.println("2) Take Me To Church - Hozier");
uone = input.nextInt();
utwo = input.nextInt();
switch (one){
case 1:
//code goes here for option 1
System.out.println("");
System.out.println("Thank For The Memories - Fall Out Boy Lyrics");
System.out.println(" == ");
System.out.println("I'm gonna make it bend and break");
System.out.println("Say a prayer but let the good times roll");
System.out.println("In case God doesn't show");
System.out.println("(Let the good times roll, let the good times roll)");
System.out.println("And I want these words to make things right");
System.out.println("But it's the wrongs that make the words come to life");
System.out.println("Who does he think he is?");
System.out.println("Who does he think he is?");
System.out.println("Better put your fingers back to the keys");
//continue song here
break;
case 2:
//retype all code her for it to reset
System.out.println("");
System.out.println("Take Me To Church - Hozier");
System.out.println(" == ");
System.out.println("My lover's got humour, She's the giggle at a funeral");
System.out.println("Knows everybody's disapproval, I should've worshipped her sooner");
System.out.println("If the heavens ever did speak, She's the last true mouthpiece");
System.out.println("Every Sunday's getting more bleak, A fresh poison each week");
System.out.println("We were born sick you heard them say it");
System.out.println("My church offers no absolutes, She tells me Worship in the bedroom");
break;
}
while (uone == one){
System.out.println("");
System.out.println("<-=LYRICS ABOVE=->");
System.out.println("<-=OPTIONS=->");
System.out.println("Press the number beside the song to see the lyrics!");
System.out.println("1) Thank For The Memories - Fall Out Boy");
System.out.println("2) Take Me To Church - Hozier");
uone = input.nextInt();
utwo = input.nextInt();
switch (one){
case 1:
//code goes here for option 1
System.out.println("");
System.out.println("Thank For The Memories - Fall Out Boy Lyrics");
System.out.println(" == ");
System.out.println("I'm gonna make it bend and break");
System.out.println("Say a prayer but let the good times roll");
System.out.println("In case God doesn't show");
System.out.println("(Let the good times roll, let the good times roll)");
System.out.println("And I want these words to make things right");
System.out.println("But it's the wrongs that make the words come to life");
System.out.println("Who does he think he is?");
System.out.println("Who does he think he is?");
System.out.println("Better put your fingers back to the keys");
//continue song here
break;
case 2:
//retype all code her for it to reset
System.out.println("");
System.out.println("Take Me To Church - Hozier");
System.out.println(" == ");
System.out.println("My lover's got humour, She's the giggle at a funeral");
System.out.println("Knows everybody's disapproval, I should've worshipped her sooner");
System.out.println("If the heavens ever did speak, She's the last true mouthpiece");
System.out.println("Every Sunday's getting more bleak, A fresh poison each week");
System.out.println("We were born sick you heard them say it");
System.out.println("My church offers no absolutes, She tells me Worship in the bedroom");
break;
}
}
}
}
import java.util.Scanner;
公开课歌词{
公共静态void main(字符串参数[]){
扫描仪输入=新扫描仪(System.in);
int一、二、uone、utwo;
1=1;
二=2;
System.out.println(“欢迎使用歌词查找器!”);
System.out.println(“按歌曲旁边的数字查看歌词!”);
System.out.println(“1)感谢记忆-失恋男孩”);
System.out.println(“2)带我去教堂-霍泽尔”);
uone=input.nextInt();
utwo=input.nextInt();
开关(一){
案例1:
//这里是选项1的代码
System.out.println(“”);
System.out.println(“感谢记忆-男孩的歌词”);
System.out.println(“=”);
System.out.println(“我要让它弯曲并断裂”);
System.out.println(“祈祷,但让美好时光滚滚而来”);
System.out.println(“以防上帝不出现”);
System.out.println(“(让好时光滚滚,让好时光滚滚)”;
System.out.println(“我想用这些词来纠正错误”);
System.out.println(“但正是错误让这些词变得生动”);
他以为他是谁;
他以为他是谁;
System.out.println(“最好把手指放回键上”);
//在这里继续唱歌
打破
案例2:
//重新键入所有代码,使其复位
System.out.println(“”);
System.out.println(“带我去教堂-霍泽尔”);
System.out.println(“=”);
我的爱人很幽默,她是葬礼上的笑料;
知道每个人都不赞成,我应该早点崇拜她;
如果上天真的说了,她是最后一个真正的喉舌;
println(“每个星期天都越来越阴冷,每周都有新的毒药”);
println(“我们生下来就生病了,你听到他们这么说”);
System.out.println(“我的教堂没有提供绝对,她告诉我在卧室里崇拜”);
打破
}
而(uone==一){
System.out.println(“”);
System.out.println(“”);
System.out.println(“”);
System.out.println(“按歌曲旁边的数字查看歌词!”);
System.out.println(“1)感谢记忆-失恋男孩”);
System.out.println(“2)带我去教堂-霍泽尔”);
uone=input.nextInt();
utwo=input.nextInt();
开关(一){
案例1:
//这里是选项1的代码
System.out.println(“”);
System.out.println(“感谢记忆-男孩的歌词”);
System.out.println(“=”);
System.out.println(“我要让它弯曲并断裂”);
System.out.println(“祈祷,但让美好时光滚滚而来”);
System.out.println(“以防上帝不出现”);
System.out.println(“(让好时光滚滚,让好时光滚滚)”;
System.out.println(“我想用这些词来纠正错误”);
System.out.println(“但正是错误让这些词变得生动”);
他以为他是谁;
他以为他是谁;
System.out.println(“最好把手指放回键上”);
//在这里继续唱歌
打破
案例2:
//重新键入所有代码,使其复位
System.out.println(“”);
System.out.println(“带我去教堂-霍泽尔”);
System.out.println(“=”);
我的爱人很幽默,她是葬礼上的笑料;
知道每个人都不赞成,我应该早点崇拜她;
如果上天真的说了,她是最后一个真正的喉舌;
println(“每个星期天都越来越阴冷,每周都有新的毒药”);
println(“我们生下来就生病了,你听到他们这么说”);
System.out.println(“我的教堂没有提供绝对,她告诉我在卧室里崇拜”);
打破
}
}
}
}
当用户键入数字1时,应将其输出:
System.out.println("");
System.out.println("Thank For The Memories - Fall Out Boy Lyrics");
System.out.println(" == ");
System.out.println("I'm gonna make it bend and break");
System.out.println("Say a prayer but let the good times roll");
System.out.println("In case God doesn't show");
System.out.println("(Let the good times roll, let the good times roll)");
System.out.println("And I want these words to make things right");
System.out.println("But it's the wrongs that make the words come to life");
System.out.println("Who does he think he is?");
System.out.println("Who does he think he is?");
System.out.println("Better put your fingers back to the keys");
//continue song here
break;
while (uone == one){
System.out.println("");
System.out.println("<-=LYRICS ABOVE=->");
System.out.println("<-=OPTIONS=->");
System.out.println("Press the number beside the song to see the lyrics!");
System.out.println("1) Thank For The Memories - Fall Out Boy");
System.out.println("2) Take Me To Church - Hozier");
System.out.println("");
System.out.println("Take Me To Church - Hozier");
System.out.println(" == ");
System.out.println("My lover's got humour, She's the giggle at a funeral");
System.out.println("Knows everybody's disapproval, I should've worshipped her sooner");
System.out.println("If the heavens ever did speak, She's the last true mouthpiece");
System.out.println("Every Sunday's getting more bleak, A fresh poison each week");
System.out.println("We were born sick you heard them say it");
System.out.println("My church offers no absolutes, She tells me Worship in the bedroom");
break;
while (uone == one){
System.out.println("");
System.out.println("<-=LYRICS ABOVE=->");
System.out.println("<-=OPTIONS=->");
System.out.println("Press the number beside the song to see the lyrics!");
System.out.println("1) Thank For The Memories - Fall Out Boy");
System.out.println("2) Take Me To Church - Hozier");
System.out.println(“”);
System.out.println(“感谢记忆-男孩的歌词”);
System.out.println(“=”);
System.out.println(“我要让它弯曲并断裂”);
System.out.println(“祈祷,但让美好时光滚滚而来”);
System.out.println(“以防上帝不出现”);
System.out.println(“(让好时光滚滚,让好时光滚滚)”;
System.out.println(“我想用这些词来纠正错误”);
System.out.println(“但正是错误让这些词变得生动”);
他以为他是谁;
他以为他是谁;
System.out.println(“Bett
uone = input.nextInt();
utwo = input.nextInt();
switch (one){
int choice = input.nextInt();
switch (choice)