Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the methods in IntegerName.java so that it works for integers up to 1 million. Modify the main method so that it can read in

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Modify the methods in IntegerName.java so that it works for integers up to 1 million. Modify the main method so that it can read in the value of a check. Then using the modified methods print out the value of the check in words (both the dollar and cent values). Test your program using 3 different inputs. import java.util.Scanner; This program turns an integer into its English name. public class IntegerName public static void main(String[] args) Scanner in - new Scanner (System.in); System.out.print( "Please enter a positive integer1000:" int input = in.next Int(); System.out.println(intName(input)) Turns a number into its English name. @param number a positive integer = 100) name- digitName (part / 100) +" hundred"; part = part % 100; if (part >= 20) name - name +""ttensName (part) part part % 10; else if (part >- 10) else if (part >10) teenName (part); name-name +"" 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 "oe... "nine") public static String digitName(int digit) if (digit1) return "one if (digit 2) return "two" if (digit3) return "three h (digit 4) return "four"; if (digit 5) if (digit6) f return "six"; ) if (digit - 7) return "seven" ) if (digit8) return "eight"; h if (digit 9) return "nine"h return""; return "five"h its English name 19 ("ten" "nineteen") Turns a number between 10 and 19 into Eparam number an integer between 10 and return the name of the given number public static String teenName (int number) public static String teenName(int number) if (number 10) return "ten if (number 11) return "eleven"; ) if (number 12) return "twelve") if (number13) return "thirteen") if (number 14) return "fourteen"; ) if (number 15) return "fifteen" if (number 16) return "sixteen" if (number17) 1 return "seventeen" if (number18) return "eighteen") if (number 19) return "nineteen" > return""; * t Gives the name of the tens part of a 2param number an integer between 20 and greturn the name of the tens part of the number between 20 and 99. 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"; 1 if (number >- 20) return "twenty"; > return

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

1 5 8 . ' '

Answered: 1 week ago