developing the quiz code

SUPERIOR-PAPERS.COM essay writing company is the ideal place for homework help. If you are looking for affordable, custom-written, high-quality and non-plagiarized papers, your student life just became easier with us. Click the button below to place your order.


Order a Similar Paper Order a Different Paper

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

Submission Details:

  • Create the code and sample run files as described.
  • Zip all the java files

"Is this question part of your assignment? We can help"

ORDER NOW
Writerbay.net

Got stuck with a writing task? We can help! Use our paper writing service to score better grades and meet your deadlines.

Get 15% discount for your first order


Order a Similar Paper Order a Different Paper
Writerbay.net