import java.awt.Graphics;
import javax.swing.*;
import java.awt.*;
public class quiz extends JApplet
{
double t;
int corCount;
String input1;
String input2;
String input3;
String input4;
String input5;
String input6;
String input7;
String input8;
String input9;
String input10;
public void init(){
try{
JOptionPane.showMessageDialog(null,
"Welcome to the quiz.\n\n" +
"For multiple choice questions, enter the best LETTER.\n" +
"For true / false quetions, enter 'T' or 'F'.\n\n" +
"This quiz consists of 10 questions.",
"R E A D T H I S M E S S A G E !",
JOptionPane.WARNING_MESSAGE);
input1 = JOptionPane.showInputDialog(null,
"True or False:\n" +
"Cancer cells can mutilate and become resistent to\n" +
"chemotherapy drugs.\n", "TRUE OR FALSE ('T' or 'F')",
JOptionPane.INFORMATION_MESSAGE);
if (input1.equals("T") || input1.equals("t")) {
corCount++;
}
input2 = JOptionPane.showInputDialog(null,
"Multiple Choice:\n" +
"Ectoderm gives rise to which of the following:\n\n" +
"A nerve+skin\n" +
"B internal organs\n" +
"C muscles and bone\n" +
"D all of the above\n",
"Multiple Choice",
JOptionPane.INFORMATION_MESSAGE);
if (input2.equals("A") || input2.equals("a")) {
corCount++;
}
input3 = JOptionPane.showInputDialog(null,
"True or False:\n" +
"The hair-like structures covering the\n" +
"paramicium are flagella.\n", "TRUE OR FALSE ('T' or 'F')",
JOptionPane.INFORMATION_MESSAGE);
if (input3.equals("F") || input3.equals("f")) {
corCount++;
}
input4 = JOptionPane.showInputDialog(null,
"True or False:\n" +
"The chloroplast detects light in a euglena.\n"
, "TRUE OR FALSE ('T' or 'F')",
JOptionPane.INFORMATION_MESSAGE);
if (input4.equals("F") || input4.equals("f")) {
corCount++;
}
input5 = JOptionPane.showInputDialog(null,
"Multiple Choice:\n" +
"While cloning, a specialized cell nucleus is inserted into:\n\n" +
"A another specialized cell\n" +
"B a normal egg\n" +
"C an egg that had its nucleus removed\n" +
"D the uterus of a female\n",
"Multiple Choice",
JOptionPane.INFORMATION_MESSAGE);
if (input5.equals("C") || input5.equals("c")) {
corCount++;
}
input6 = JOptionPane.showInputDialog(null,
"True or False:\n" +
"100,000,000,000 neurons are in a piece of tissue the size of a grain of rice.\n"
, "TRUE OR FALSE ('T' or 'F')",
JOptionPane.INFORMATION_MESSAGE);
if (input6.equals("F") || input6.equals("f")) {
corCount++;
}
input7 = JOptionPane.showInputDialog(null,
"True or False:\n" +
"The PR is in the bottom of the bud of the hand.\n"
, "TRUE OR FALSE ('T' or 'F')",
JOptionPane.INFORMATION_MESSAGE);
if (input7.equals("T") || input7.equals("t")) {
corCount++;
}
input8 = JOptionPane.showInputDialog(null,
"True or False:\n" +
"The SRC gene is the key to determining gender.\n"
, "TRUE OR FALSE ('T' or 'F')",
JOptionPane.INFORMATION_MESSAGE);
if (input8.equals("F") || input8.equals("f")) {
corCount++;
}
input9 = JOptionPane.showInputDialog(null,
"True or False:\n" +
"Select the gene rules of pairing.\n\n" +
"A T,C and A,G\n" +
"B A,T and G,C\n" +
"C T,G and A,C\n" +
"D both b and c\n"
, "TRUE OR FALSE ('T' or 'F')",
JOptionPane.INFORMATION_MESSAGE);
if (input9.equals("B") || input9.equals("b")) {
corCount++;
}
input10 = JOptionPane.showInputDialog(null,
"True or False:\n" +
"Cells need glucose to construct new parts.\n"
, "TRUE OR FALSE ('T' or 'F')",
JOptionPane.INFORMATION_MESSAGE);
if (input10.equals("T") || input10.equals("t")) {
corCount++;
}
if (corCount >= 8) {
JOptionPane.showMessageDialog(null,
"\nNumber Correct: " + corCount + " / 10",
"Congratulations!!!",
JOptionPane.INFORMATION_MESSAGE);
}
else if (corCount >= 5) {
JOptionPane.showMessageDialog(null,
"\nNumber Correct: " + corCount + " / 10",
"Better Luck Next Time...",
JOptionPane.INFORMATION_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null,
"\nNumber Correct: " + corCount + " / 10",
"Go Back to Preschool",
JOptionPane.INFORMATION_MESSAGE);
}
}
catch(Exception e){
}
}
public void nothing(){
try{
//this method halts the program - does nothing, hence the name nothing
}
catch(Exception e3){
}
}
public void paint(Graphics g)
{
super.paint(g);
try{
g.setFont(new Font("arial", Font.BOLD, 16));
g.drawString(" Q U I Z ! ! ! ", 115, 15);
g.drawRoundRect(45, 30, 270, 20, 15, 15);
g.setFont(new Font("arial", Font.BOLD + Font.ITALIC, 14));
g.drawString("Questions Correct: " + corCount + " out of 10", 50, 45);
g.setFont(new Font("arial", Font.PLAIN, 12));
g.drawString("Your Input:", 155, 70);
g.drawString("1.) " + input1 + " ", 10, 80);
g.drawString("6.) " + input6 + " \n", 300, 80);
g.drawString("2.) " + input2 + " ", 10, 100);
g.drawString("7.) " + input7 + " \n", 300, 100);
g.drawString("3.) " + input3 + " ", 10, 120);
g.drawString("8.) " + input8 + " \n", 300, 120);
g.drawString("4.) " + input4 + " ", 10, 140);
g.drawString("9.) " + input9 + " \n", 300, 140);
g.drawString("5.) " + input5 + " ", 10, 160);
g.drawString("10.) " + input10 + " \n", 300, 160);
String in = JOptionPane.showInputDialog(null,
"Type \"answers\" to view the answers,\n" +
"\"exit\" to exit, and \"ignore\" to ignore this message.",
"Answers",
JOptionPane.QUESTION_MESSAGE);
if (in.equals("answers") || in.equals("ANSWERS")) {
JOptionPane.showMessageDialog(null,
"Answers (Correct Letter)\n\n" +
"1.) Cancer cells can mutilate to become resistent to chemo ( T )\n\n" +
"2.) Ectoderm gives rise to nerve and skin ( A )\n\n" +
"3.) Hair structures are called cilia ( F )\n\n" +
"4.) The eyespot detects light ( F )\n\n" +
"5.) Cell nucleus is inserted into an cell without a nucleus ( C )\n\n" +
"6.) 100,000 neurons in brain tissue are about the size of rice ( F )\n\n" +
"7.) The PR is at the bottom of the hand bud ( T )\n\n" +
"8.) The SRY gene is the key to determining gender ( F )\n\n" +
"9.) A,T and G,C are the rules of pairing ( B )\n\n" +
"10.) Cells need raw materials to construct new parts ( T )",
"Answers",
JOptionPane.WARNING_MESSAGE);
nothing();
}
else if (in.equals("exit") || in.equals("EXIT")) {
System.exit(0);
}
else {
nothing();
}
}
catch(Exception e2){
}
}
}