Question: Develop a java program to read a number from keyboard maximum three digits long as a long integer, and print it in alphabetic spelling form.
Develop a java program to read a number from keyboard maximum three digits long as a long integer, and print it in alphabetic spelling form. Consider the following Java code fragment: String[] oneDigit = {""," one", " two", " three", " four"}; String ans = oneDigit[2]; // Now ans is equal to " two" We can find alphabetic representation of a one digit number using array and index of the array. Study pattern of the numbers and discover how they are repeating themselves, like: 222 that is two hundred twenty two Notes: 1. To accomplish the task you need two or three separate arrays of Strings. The length of each array is about ten to twenty elements that depends on your design. 2. You need a right algorithm to achieve the goal. Note that the assignment is easy provided that you think about your algorithm first. 3. Think about modulus and division of numbers and using them as index of your arrays. 4. Use procedural abstraction and split your program into smaller methods. Phase Phase 2: [20 marks] Expand your program to numbers up to 15-digits long. Note that a long integer can hold a number up to 15-digits long, and it is much easier if you read your number as a long integer. Now study the pattern of the numbers. For example: 222222222 that is two hundred twenty two million, and two hundred twenty two thousand, and two hundred twenty two. As you can see from above example, the pattern is just repeated, and the only difference is the suffix of the: million, thousand, and nothing (an empty string). Important notes: 1. Use arrays of strings. 2. Avoid using excessive if-else statements. 3. Think about arrays, index of arrays, and loops.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
