0

How do I change the value of users into a word, e.g. when I run the code and input 5 users, it will count down from 5 to 0, but I want to change 5 to five, 4 to four 3 to three etc. I used an if statement if userU == 5 and tried to return it and tried to use it in the println (bot(option)), So I am confused how to do this in 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(" ");     
  • I saw that, it kind of understand, but how would I apply that towards my scanner which asks for an input? – noobzor287 Feb 08 '18 at 15:20
  • *"but how would I apply that towards my scanner which asks for an input?"* You take your input as an `int` then pass it as: `EnglishNumberToWords.convert(userU)` to the converter class... It's not that difficult to do so... In programming you need to know and understand what another code does and then how to modify it to make it work for your own code... – Frakcool Feb 08 '18 at 16:40

0 Answers0