Question & Answer: public class NumberTcwords public static void nein(Stringl1 args) ( seventy', "eighty .eight', twenty, "thirty" fourty","fi…..

how to fix the java code?

convert the number into the word

the range i want is 0-999 and put -1 will stop the program.

public class NumberTcwords public static void nein(Stringl1 args) ( seventy, eighty .eight, twenty, thirty fourty,fifty sixty ninty nine. String[] tens { String[] units= { zero, one-, String word System.out.print( Number: ) int nun -In.nextint tno three. .four, five, six, .seven. ·ten-, eleven-, twelve, thirteen . , fourteen, fifteen . , sixteen seventeen eighteen-, ninte , while(nun-1) int hundred num 138 int ten . num/ 10%18 int unit num%18 num-19)( Systen . out.println(tens[ten] ÷ · + units[unit]); Systen.out.print1n(Nunber : ·); nun In.nextIntO: elset Systen.out.printin (units[nun]) System.out.printlnNumber:) nun-In.nextInt) f (num-0) System.out.printin(word) System.out.printin(Number): num· 1n.nextInt():

public class NumberTcwords public static void nein(Stringl1 args) ( seventy’, “eighty .eight’, twenty, “thirty” fourty”,”fifty” “sixty ‘ninty “nine.’ String[] tens { String[] units= { zero”, “one-, String word System.out.print( Number: “) int nun -In.nextint tno” “three.’ .four”, “five”, “six”, .seven.’ ·ten-, “eleven-, twelve”, thirteen . , fourteen”, “fifteen . , “sixteen “seventeen “eighteen-, “ninte , while(nun-1) int hundred num 138 int ten . num/ 10%18 int unit num%18 num-19)( Systen . out.println(tens[ten] ÷ ·” + units[unit]); Systen.out.print1n(“Nunber : ·); nun In.nextIntO: elset Systen.out.printin (units[nun]) System.out.printlnNumber:) nun-In.nextInt) f (num-0) System.out.printin(word) System.out.printin(“Number): num· 1n.nextInt():

Expert Answer

 

note:Add the hundreds place also..and also provided the output snipet..

#)code:

import java.io.*;
import java.util.Scanner;
public class NumberToWords{
public static void main(String[] args) {
String[] hundreds = {“”,”one hundred”,”two hundred”,”three hundred”,”four hundred”,”five hundred”,”six hundred”,”seven hundred”,”Eight hundred”,”nine hundred”};
String[] tens = {“”,””,”twenty”,”thirty”,”fourty”,”fifty”,”sixty”,”seventy”,”eighty”,”ninty”};
String[] units = {“Zero”,”one”,”two”,”three”,”four”,”five”,”six”,”seven”,”Eight”,”nine”,”ten”,”eleven”,”twelve”,”thirteen”,”fourteen”,”fifteen”,”sixteen”,”seventeen”,”eighteen”,”ninteen”};
String[] word = {};
System.out.print(“Number:”);
Scanner in = new Scanner(System.in);
int num=in.nextInt();
while(num!=-1){
int hundred =num/100;
int ten = num/10 %10;
int unit = num%10;
if(num>99)
{
System.out.println(hundreds[hundred] +” “+ tens[ten] +” “+ units[unit]);
System.out.println(“Number:”);
num = in.nextInt();
}else if (num >19){
System.out.println(tens[ten] +” “+ units[unit]);
System.out.println(“Number:”);
num = in.nextInt();
}else{
System.out.println(units[unit]);
System.out.println(“Number:”);
num = in.nextInt();
}
if(num>0){
System.out.println(word);
System.out.println(“Number:”);
num = in.nextInt();
}
} //while
}//main
}//class

output:

Still stressed from student homework?
Get quality assistance from academic writers!