Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(*Use Netbeans or hardcode if you choose to use a GUI over console app.) Write a java program that demonstrates recursion. This program can be

(*Use Netbeans or hardcode if you choose to use a GUI over console app.)

Write a java program that demonstrates recursion. This program can be in a java GUI frame or as a console application. On this one it is up to you. (It would probably work better as a console program for this particular program.)

The input for this program is a number of boxes. Ask the user for this with a textbox or a prompt on the command line.

Demonstrate recursion with a function called LoadTruck() that takes a number of boxes to be packed as a parameter. This function should print Truck Loaded and subtract 5 from the number of boxes and recursively call itself until there are less than 5 boxes. That time through it should print There are not enough to pack another truck.

(If you wish to use a GUI, it might be best to print the lines by concatenating them onto the text in a textArea along with a newline character. There may be other ways you can think of to do this in a GUI using other controls. Anyway you display the trucks loaded is fine.)

This program must have a recursive method. If you use a loop to load the trucks it will not count for any of the points for this one. This lab is to demonstrate recursion.

Example of output for 23 boxes:

Truck Loaded

Truck Loaded

Truck Loaded

Truck Loaded

There are not enough to pack another truck.

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

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions

Question

How will these issues affect the grade levels you will teach?

Answered: 1 week ago

Question

Choosing Your Topic Researching the Topic

Answered: 1 week ago

Question

The Power of Public Speaking Clarifying the

Answered: 1 week ago