ITS 3105 SUS Programming ll Questions

Description

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
            }
}

Tags:
R code

Programming Code

Java files

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

Reviews, comments, and love from our customers and community:

Article Writing

Keep doing what you do, I am really impressed by the work done.

Alexender

Researcher

PowerPoint Presentation

I am speechless…WoW! Thank you so much!

Stacy V.

Part-time student

Dissertation & Thesis

This was a very well-written paper. Great work fast.

M.H.H. Tony

Student

Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time.

Francisca N.

Student

Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more.

Mary J.

Student

Essay (Any Type)

On time, perfect paper

Prof. Kate (Ph.D)

Student

Case Study

Awesome! Great papers, and early!

Kaylin Green

Student

Proofreading & Editing

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Rebecca L.

Researcher

Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. Transparent

Arnold W.

Customer

Coursework

Perfect!

Joshua W.

Student

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>