Java将数字值转换为循环中的文本值

时间:2018-02-08 15:04:46

标签: java

如何将用户的值更改为单词,例如当我运行代码并输入5个用户时,它会从5倒数到0,但我想要改变5到5,4到4到3等等。如果userU == 5我尝试返回我使用if语句它并尝试在println(bot(选项))中使用它,所以我很困惑如何在java中这样做。

Scanner userIn = new Scanner(System.in);                                        
System.out.println("Enter amount");                                     
int userU = userIn.nextInt();   

if (userU == 5);                                        
{                                       
  String option = "one";                                        
}        

while(userU>2){                                                                             
  System.out.println(userU+" users");                                                                       
  System.out.println("There'll be "+(userU-1) + " left");                                       
  System.out.println(" ");                                      
  userU = userU-1;                                      
}                                       
while(userU>1){                         
  System.out.println(userU+" users left");                                                                          
  System.out.println("There'll be "+(userU-1) + " left");                                       
  System.out.println(" ");                                      
  userU = userU-1;                                      
}                                       

System.out.println("There'll be "+ (userU-1)+" left.");                                     
System.out.println(" ");     

0 个答案:

没有答案