Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program with a Graphical User Interface (GUI) that converts a number fro

ID: 3778756 • Letter: W

Question

Write a program with a Graphical User Interface (GUI) that converts a number from one to 99 to its English equivalence. You will need two arrays of Strings, one with the names of the numbers from zero to nine. Use an empty string for the value of zero. The other array of Strings should contain the names of the tens digits (i.e. "twenty", "thirty", etc.) from twenty to ninety. The numbers ten, eleven and twelve should be handled first as a special case. For numbers less than ten. just use the number as the index into the number name array. For numbers in the teens, concatenate the name of the single digit before the word "teen". (We will ignore the three teen and fifteen issues.) For numbers twenty and over, concatenate the tens digit (indexed by number/10) with the ones digit (indexed by number % 10). You may format the program in any way that is effective. The use of a button is optional. A possible format could be:

Explanation / Answer

import java.util.*;

public class YourNumberMyWord

{

public void pw(int n,String ch)

{

    String one[]={" "," one"," two"," three"," four"," five"," six"," seven"," eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen","fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};

    String ten[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty","seventy"," eighty"," ninety"};

    if(n > 19) { System.out.print(ten[n/10]+" "+one[n%10]);} else { System.out.print(one[n]);}

    if(n > 0)System.out.print(ch);

}

public static void main(String[] args)

{

    int n=0;

    Scanner scanf = new Scanner(System.in);

    System.out.println("Enter an integer number: ");

    n = scanf.nextInt();

   

    if(n < = 0)                  

      System.out.println("Enter numbers greater than 0");

   }

   else

   {

      YourNumberMyWord a = new YourNumberMyWord();

      a.pw((n/1000000000)," Hundred");

      a.pw((n/10000000)%100," crore");

      a.pw(((n/100000)%100)," lakh");

      a.pw(((n/1000)%100)," thousand");

      a.pw(((n/100)%10)," hundred");

      a.pw((n%100)," ");

    }

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote