Please separate this code to two class... main class and another class main class will only run the code and the other class will have the body of the cod or the methods and other... thank you package...


Please separate this code to two class... main class and another class
main class will only run the code and


the other class will have the body of the cod or the methods and other...


thank you



package Test;


import java.util.Scanner;
public class NumbersInWords {
    public static void main(String[] args) {

        Scanner myObj = new Scanner(System.in);  // Create a Scanner object
        System.out.println("Enter Number 0 to 999,999,999:-");
        String number = myObj.nextLine();  // Read user input
        int number1 = number.length();
        String numberToWord = "";
        for (int j = 0; j < number1;="" j++)="">
            switch (number.charAt(j)) {
                case '1': {
                    numberToWord = numberToWord + "one ";
                    break;
                }
                case '2': {
                    numberToWord = numberToWord + "two ";
                    break;
                }
                case '3': {
                    numberToWord = numberToWord + "three ";
                    break;
                }
                case '4': {
                    numberToWord = numberToWord + "four ";
                    break;
                }
                case '5': {
                    numberToWord = numberToWord + "five ";
                    break;
                }
                case '6': {
                    numberToWord = numberToWord + "six ";
                    break;
                }
                case '7': {
                    numberToWord = numberToWord + "seven ";
                    break;
                }
                case '8': {
                    numberToWord = numberToWord + "eight ";
                    break;
                }
                case '9': {
                    numberToWord = numberToWord + "nine ";
                    break;
                }
                default: {
                    numberToWord = numberToWord + "zero ";
                }
            }
        }
        System.out.println(numberToWord);
    }
}



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here