Problem Description There are bunnies standing in a line, numbered 1, 2, ...n. T
ID: 3669718 • Letter: P
Question
Problem Description
There are bunnies standing in a line, numbered 1, 2, ...n. The odd bunnies (1, 3, ..) have the normal 2 ears. The even bunnies (2, 4, ..) are genetic mutations and have 3 ears. Write a GUI program which uses a recursive method, earCount(), to calculate the number of "ears" in the bunny line. The user will supply the number of bunnies in the line.
Specifications
Your program will consist of 2 Textboxes and a Button, each should be labeled appropriately. The user will enter an integer in one Textbox, press the Button, and the number of ears will be shown in the other Textbox. The second Textbox should be readonly.
Do not use loops or multiplication in your program.
Error Checking
Inputs
User input should be an integer. Give feedback if it is not and ask them to reenter.
Use a Try-Catch blocks where you deem appropriate.
Commenting
Use the generated flower box in BlueJ to provide a description of the Class and your name.
For @version – Enter the date you started writing the class in MM/DD/YYYY format.
A single line comment on each element needed for the assignment.
Example: A single line comment followed by statements to create an instance of JTextField, and call setEditable method is fine.
Significant variables descriptions.
No “loop” variables. a, b, c, x, y, z, etc.
Explanation / Answer
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class.....{
private String getdate()
{
DateFormat format = new SimpleDateFormat("MM/DD/YYYY"); //display your format.
Date date = new Date();
return dateformat.format(date);
}
public your_app
{
String date = new getdate();
txtDate.setvalue(date);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.