Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use java to answer this question Numbers to Strings Implement a static String numberToString(int n ) that converts a integer n between 1 (inclusive) and
Use java to answer this question
Numbers to Strings Implement a static String numberToString(int n ) that converts a integer n between 1 (inclusive) and one billion (exclusive) into a String. The numberToString method can cover a larger range if you wish. It should take appropriate action if the argument is out of range. For instance numberToString ( 312000789 ) should return three hundred twelve million seven hundred eighty-nine. Carefully think about how to decompose this problem. For instance, if you have a method that can handle the range 1-999, how can you use that method to create another method that handles the range 1-999999? Aim to create methods that have well-defined purposes, but which have no more than around twenty lines of code each. Exploit small private static arrays of Strings if you can. Implement a test method that provides automated testing of the numberToString method. Here, "automated" means that the test method does not require human input. Think carefully about what test cases provide good automated testing. Determine the total number of ' w 's in the words "one, two, three, .... thiry-four million nine hundred ninety-nine thousand nine hundred ninety-eight, thiry-four million nine hundred ninety-nine thousand nine hundred ninety-nine, thiry-five million." - Your program must consist of at least three classes: - one containing functions to convert positive integers to strings; - one containing test functions to test the class above; and - One to count ' w 's. - Your code should obey the following rules. - All member variables must be either private or final (both is fine). - Non-void return type functions should have minimal side-effects. Executing the same non-void function twice in a row with the same arguments should produce the same result. - Your code must conform to the follwing standards: - Class names must be capitalized. - Method names, member variables, and local variables must begin with a lower-case letter. - (exceptions) public static final variables may have all-caps names. - Methods and member variable declarations must be indented with respect to the surrounding class. - More generally, method bodies, loop bodies, and so on must be indented. English Grammar for Numbers - The first nineteen positive integers are -one-five-nine-thirteen-seventeentwosixtenfourteeneighteenthreesevenelevenfifteennineteenfoureighttwelvesixteen - The first 9 multiples of ten are: ten, twenty, thiry, forty, fifty, sixty, seventy, eighty, and ninety. - Note the spellings of four, fourteen, and forty. - Also note that eighteen has only one ' t '. - For 20n0, a hyphen and the word for b. - For 100n0, a space and the words for b. - For 103n0, a space and the words for b. - For 106n0, a space and the word(s) for b. - The word "and" is not used for integers. (one hundred and twenty-three thousandths means 100.023; whereas one hundred twenty-three thousandths means 0.123 ) Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started