ITS 3105 SUS Programming ll Questions

Follow the comments in the code below: add 8 more questions and answers and at the end tell the user how many right and wrong they got for a score.

import javax.swing.*;
public class Quiz
{
      public static void main(String[] args)
      {
             String[] questions =
                      {“How many players on a basketball team?\nA. 5 B. 6 C. 7”,
                                     “How many points for a basket?\nA. 1 B. 2 C. 3”,
                       “How many points for a free throw?\nA. 1 B.     2 C. 3”};
             //Add 8 more questions and answers
             char[] answers = {‘A’, ‘B’,’A’ };
             char ans = ‘ ‘;
             int x, correct = 0;
             String entry;
             boolean isGood;
             for(x = 0; x < questions.length; ++x)
             {
                        isGood = false;
                        int firstError = 0;
                        while(!isGood)
                        {
                               isGood = true;
                               entry = JOptionPane.showInputDialog
          (null,questions[x]);
                               ans = entry.charAt(0);
                               if(ans != ‘A’ && ans != ‘B’ && ans != ‘C’)
                               {
                                      isGood = false;
                                      if(firstError == 0)
                                      {
           questions[x] = questions[x] +
           “\nYour answer must be A, B or C.”;
                                               firstError = 1;
                                       }
                               }
                          }
                          if(ans == answers[x])
                          {
                                  ++correct;
            JOptionPane.showMessageDialog(null,
            “Correct!”);
                           }
                           else
            JOptionPane.showMessageDialog(null, “The correct answer is ” + answers[x]);
                   }
                   // Using JOptionPane.showMessageDialog tell the user how many they got right and wrong
            }
}

Calculate your order
275 words
Total price: $0.00

Top-quality papers guaranteed

54

100% original papers

We sell only unique pieces of writing completed according to your demands.

54

Confidential service

We use security encryption to keep your personal data protected.

54

Money-back guarantee

We can give your money back if something goes wrong with your order.

Enjoy the free features we offer to everyone

  1. Title page

    Get a free title page formatted according to the specifics of your particular style.

  2. Custom formatting

    Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.

  3. Bibliography page

    Don’t pay extra for a list of references that perfectly fits your academic needs.

  4. 24/7 support assistance

    Ask us a question anytime you need to—we don’t charge extra for supporting you!

Calculate how much your essay costs

Type of paper
Academic level
Deadline
550 words

How to place an order

  • Choose the number of pages, your academic level, and deadline
  • Push the orange button
  • Give instructions for your paper
  • Pay with PayPal or a credit card
  • Track the progress of your order
  • Approve and enjoy your custom paper

Ask experts to write you a cheap essay of excellent quality

Place an order