Sat Nov 27, 2010 1:38 am
//holds methods used for drivers test
import java.util.Scanner; //scanner class import
class DriverTestMethods //class name
{
private String[] answers = { "B", "D", "A", "A", "C", "A", "B", "A",
"C", "D", "B", "C", "D", "A", "D", "C",
"C", "B", "D", "A" }; //the real answers.
private String[] inputted; //inputted answers
private String[] questions; //displays questions.
private int correct = 0; //holds amount of correct answers.
private int incorrect = 0; //holds amount of incorrect answers.
private int qcounter = 1; //counts questions til 20.
private int index = 0;
Scanner keyboard = new Scanner(System.in);// holds input
void testBegin()
{
do
{
System.out.println("Question " + qcounter +" goes here");
inputted[index] = keyboard.next();
if(inputted[index] == answers[index])
{
correct++;
}
else
{
incorrect++;
}
qcounter+=1;
index+=1;
}while (qcounter != 21);
passed();
}
void passed()
{
if(correct >= 15)
{
System.out.println("Good job, you passed!");
System.out.println("Correct: " + correct);
System.out.println("Incorrect: " + incorrect);
}
else
if(incorrect >= 5)
{
System.out.println("Sorry, You Suck!!");
System.out.println("Correct: " + correct);
System.out.println("Incorrect: " + incorrect);
}
System.exit(0);
}
}
Sat Nov 27, 2010 5:43 am
private String inputted; //inputted answers
inputted = keyboard.next();
inputted.equals(answers[index]
//holds methods used for drivers test
import java.util.Scanner; //scanner class import
class DriverTestMethods //class name
{
private String[] answers = { "B", "D", "A", "A", "C", "A", "B", "A",
"C", "D", "B", "C", "D", "A", "D", "C",
"C", "B", "D", "A" }; //the real answers.
private String inputted; //inputted answers
private String[] questions; //displays questions.
private int correct = 0; //holds amount of correct answers.
private int incorrect = 0; //holds amount of incorrect answers.
private int qcounter = 1; //counts questions til 20.
private int index = 0;
Scanner keyboard = new Scanner(System.in);// holds input
void testBegin()
{
do
{
System.out.println("Question " + qcounter +" goes here");
inputted = keyboard.next();
if(inputted.equals(answers[index]))
{
correct++;
}
else
{
incorrect++;
}
qcounter+=1;
index+=1;
}while (qcounter != 21);
passed();
}
void passed()
{
if(correct >= 15)
{
System.out.println("Good job, you passed!");
System.out.println("Correct: " + correct);
System.out.println("Incorrect: " + incorrect);
}
else
if(incorrect >= 5)
{
System.out.println("Sorry, You Suck!!");
System.out.println("Correct: " + correct);
System.out.println("Incorrect: " + incorrect);
}
System.exit(0);
}
}
Sun Nov 28, 2010 12:59 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.