Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please dont waste my question if you cant do it. Thank you. Above you should see a .java file: RecursionDemo. You are to create GUI

Please dont waste my question if you cant do it. Thank you.

Above you should see a .java file: RecursionDemo. You are to create GUI for this program. It must allow user input and program output. Design your GUI to follow the functionality of the the original programs. In other words, familiarize yourself with how each of the programs work before attempting your GUI version. This time try to make your GUI user friendly. Tell the user what they must do and what outcome to expect.

Add comments to code please.

import java.util.Scanner; public class RecursionDemo { public static void main(String[] args) { System.out.println("Enter an integer:"); Scanner keyboard = new Scanner(System.in);; int number = keyboard.nextInt( ); System.out.println("The digits in that number are:"); displayAsWords(number); System.out.println( ); System.out.println("If you add ten to that number, "); System.out.println("the digits in the new number are:"); number = number + 10; displayAsWords(number); System.out.println( ); } /** Precondition: number >= 0 Displays the digits in number as words. */ public static void displayAsWords(int number) { if (number < 10) System.out.print(getWordFromDigit(number) + " "); else //number has two or more digits { displayAsWords(number / 10); System.out.print(getWordFromDigit(number % 10) + " "); } } /** Precondition: 0 <= digit <= 9 Returns the word for the argument digit. */ private static String getWordFromDigit(int digit) { String result = null; switch (digit) { case 0: result = "zero"; break; case 1: result = "one"; break; case 2: result = "two"; break; case 3: result = "three"; break; case 4: result = "four"; break; case 5: result = "five"; break; case 6: result = "six"; break; case 7: result = "seven"; break; case 8: result = "eight"; break; case 9: result = "nine"; break; default: System.out.println("Fatal Error."); System.exit(0); break; } return result; } } 

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

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

LO3 Define the difference between job satisfaction and engagement.

Answered: 1 week ago