he intName method in the "Problem Solving: Stepwise Refinement" section accepted arguments < 1,000. Using a recursive call, extend its range to 999,999. For example an input of 12,345 should return " twelve thousand three hundred forty five". Note that some number names may have extra spaces at the beginning or end. import java.util.Scanner; public class IntegerName { /** Turns a number into its English name. @param number a positive integer < 999,999 @return the name of the number (e.g. "two hundred seventy four") */ public static String intName(int number) { int part = number; // The part that still needs to be converted String name = ""; // The name of the number if (part >= 1000) { // Recursively call intName } if (part >= 100) { name = digitName(part / 100) + " hundred"; part = part % 100; } if (part >= 20) { name = name + " " + tensName(part); part = part % 10; } else if (part >= 10) { name = name + " " + teenName(part); part = 0; } if (part > 0) { name = name + " " + digitName(part); } return name; } /** Turns a digit into its English name. @param digit an integer between 1 and 9 @return the name of digit ("one" ... "nine") */ public static String digitName(int digit) { if (digit == 1) { return "one"; } if (digit == 2) { return "two"; } if (digit == 3) { return "three"; } if (digit == 4) { return "four"; } if (digit == 5) { return "five"; } if (digit == 6) { return "six"; } if (digit == 7) { return "seven"; } if (digit == 8) { return "eight"; } if (digit == 9) { return "nine"; } return ""; } /** Turns a number between 10 and 19 into its English name. @param number an integer between 10 and 19 @return the name of the given number ("ten" ... "nineteen") */ public static String teenName(int number) { if (number == 10) { return "ten"; } if (number == 11) { return "eleven"; } if (number == 12) { return "twelve"; } if (number == 13) { return "thirteen"; } if (number == 14) { return "fourteen"; } if (number == 15) { return "fifteen"; } if (number == 16) { return "sixteen"; } if (number == 17) { return "seventeen"; } if (number == 18) { return "eighteen"; } if (number == 19) { return "nineteen"; } return ""; } /** Gives the name of the tens part of a number between 20 and 99. @param number an integer between 20 and 99 @return the name of the tens part of the number ("twenty" ... "ninety") */ public static String tensName(int number) { if (number >= 90) { return "ninety"; } if (number >= 80) { return "eighty"; } if (number >= 70) { return "seventy"; } if (number >= 60) { return "sixty"; } if (number >= 50) { return "fifty"; } if (number >= 40) { return "forty"; } if (number >= 30) { return "thirty"; } if (number >= 20) { return "twenty"; } return ""; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int number = in.nextInt(); System.out.println(intName(number)); } } 1: Compare output Input 1000 Your output one thousand 2: Compare output Output differs. See highlights below. Special character legend Input 12345 Your output three hundred forty five Expected output twelve thousand three hundred forty five 3: Compare output Output differs. See highlights below. Special character legend Input 75915 Your output nine hundred fifteen Expected output seventy five thousand nine hundred fifteen with out changing any code.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The intName method in the "Problem Solving: Stepwise Refinement" section accepted arguments < 1,000. Using a recursive call, extend its range to 999,999. For example an input of 12,345 should return " twelve thousand three hundred forty five". Note that some number names may have extra spaces at the beginning or end. import java.util.Scanner; public class IntegerName { /** Turns a number into its English name. @param number a positive integer < 999,999 @return the name of the number (e.g. "two hundred seventy four") */ public static String intName(int number) { int part = number; // The part that still needs to be converted String name = ""; // The name of the number if (part >= 1000) { // Recursively call intName } if (part >= 100) { name = digitName(part / 100) + " hundred"; part = part % 100; } if (part >= 20) { name = name + " " + tensName(part); part = part % 10; } else if (part >= 10) { name = name + " " + teenName(part); part = 0; } if (part > 0) { name = name + " " + digitName(part); } return name; } /** Turns a digit into its English name. @param digit an integer between 1 and 9 @return the name of digit ("one" ... "nine") */ public static String digitName(int digit) { if (digit == 1) { return "one"; } if (digit == 2) { return "two"; } if (digit == 3) { return "three"; } if (digit == 4) { return "four"; } if (digit == 5) { return "five"; } if (digit == 6) { return "six"; } if (digit == 7) { return "seven"; } if (digit == 8) { return "eight"; } if (digit == 9) { return "nine"; } return ""; } /** Turns a number between 10 and 19 into its English name. @param number an integer between 10 and 19 @return the name of the given number ("ten" ... "nineteen") */ public static String teenName(int number) { if (number == 10) { return "ten"; } if (number == 11) { return "eleven"; } if (number == 12) { return "twelve"; } if (number == 13) { return "thirteen"; } if (number == 14) { return "fourteen"; } if (number == 15) { return "fifteen"; } if (number == 16) { return "sixteen"; } if (number == 17) { return "seventeen"; } if (number == 18) { return "eighteen"; } if (number == 19) { return "nineteen"; } return ""; } /** Gives the name of the tens part of a number between 20 and 99. @param number an integer between 20 and 99 @return the name of the tens part of the number ("twenty" ... "ninety") */ public static String tensName(int number) { if (number >= 90) { return "ninety"; } if (number >= 80) { return "eighty"; } if (number >= 70) { return "seventy"; } if (number >= 60) { return "sixty"; } if (number >= 50) { return "fifty"; } if (number >= 40) { return "forty"; } if (number >= 30) { return "thirty"; } if (number >= 20) { return "twenty"; } return ""; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int number = in.nextInt(); System.out.println(intName(number)); } } 1: Compare output Input 1000 Your output one thousand 2: Compare output Output differs. See highlights below. Special character legend Input 12345 Your output three hundred forty five Expected output twelve thousand three hundred forty five 3: Compare output Output differs. See highlights below. Special character legend Input 75915 Your output nine hundred fifteen Expected output seventy five thousand nine hundred fifteen with out changing any code.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education