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

My program works fine but here is part of my programming assignmentthat I\'m not

ID: 3613708 • Letter: M

Question

My program works fine but here is part of my programming assignmentthat I'm not sure how to do.

This time, the user is somewhat intelligent. In this case, thatmeans if he enters a value, it
will be a properly formatted integer.However, sometimes he forgetsto type something and hits OK, and sometimes he hits CANCEL. Ifeither of these cases happen, you should display a dialog boxinforming
the user that he is required to enter 10 integers.

Below is my program code.

import javax.swing.JOptionPane;

public class TwoLargest
{
    public static void main(String[] args)
    {
        //String number[9];
        //String number;
        int number;
        int largest;
        int secondLargest;

        largest =Integer.MIN_VALUE;
        secondLargest =Integer.MIN_VALUE;

       JOptionPane.showMessageDialog(null, "Welcome To The Two LargestSolver Program.");

        for (int count = 1;count < 11; count++)
        {
           do
           {
              String message = String.format
                          ("Enter Interger %s Current Largest: %s Second Largest: %s",
                          count, largest, secondLargest);

              String input = JOptionPane.showInputDialog(null, message);
              number = Integer.parseInt(input);

              if (secondLargest < number)
              {
                  if (largest < number)
                  {
                      secondLargest = largest;
                      largest = number;
                  }
                  else if (secondLargest < number && largest >number)
                  {
                      secondLargest = number;
                  }
              }
           }while(number<0);
        }

        String endMessage =String.format
                     ("The Final Result: Current Largest: %s Second Largest: %s",
                     largest, secondLargest);

       JOptionPane.showMessageDialog(null, endMessage);
   }
}


Explanation / Answer

x.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote