Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an app with a button and a text field. Display the current count in the t

ID: 3873930 • Letter: C

Question

Create an app with a button and a text field. Display the current count in the text field (display 0 when the app loads). Code each of these tasks as separate apps: a. Count up to 20, then automatically start back at 1 (instead of reaching 21). b. Count up by one for each button press for the first 10 presses, then count up by 2 for the next 10 presses, 3 for the next 10, and so on. c. Count up using the Fibonacci sequence. This sequence starts at 1. On the first press add 1, then 2, then 3, then 5, then 8, and so on. d. Count up from 1 to 10 then back down from 10 to 1, adding or subtracting 1 for each button press. When it hits 1, start counting back up again. *Should be a gui in JAVA!

Explanation / Answer

class CountThread extends Thread

{

public CountThread(JComboBox cCombo)

{

   combobox = cCombo;

   generators = new Random();

}

public void run()

{

   try

   {

     while (!interrupted())

     {

      int j = Math.abs(generators.nextInt());

      if (j % 2 == 0)

        combo.insertItem(new Integer(j), 0);

      else if (combo.getCount() > 0)

        combo.removeItem(j % combo.getCount());

     

      sleep(1);

     }

   }

   catch (InterruptedException exception) {}

}

private JComboBox ccombo;

private Random generators;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote