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
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);
}
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)