Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NumberToWords {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String input = args[0];
- String output = "";
- int index = 0;
- while(index < 3) {
- switch(input.charAt(index)) {
- case '1':
- output = output + "One ";
- break;
- case '2':
- output = output + "Two ";
- break;
- case '3':
- output = output + "Three ";
- break;
- case '4':
- output = output + "Four ";
- break;
- case '5':
- output = output + "Five ";
- break;
- case '6':
- output = output + "Six ";
- break;
- case '7':
- output = output + "Seven ";
- break;
- case '8':
- output = output + "Eight ";
- break;
- case '9':
- output = output + "Nine ";
- break;
- case '0':
- output = output + "Zero ";
- break;
- }
- index++;
- }
- System.out.println(output);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement