|
-
May 14th, 2012, 10:10 PM
#1
help! :)
is anyone available to help steer me in the right direction on completing my drivers exam program? i have posted below what i have already. help would be hugely appreciated!..
import java.util.Scanner;
public class DriverExam
{
public static void main(String[] args)
{
int[] Wrong;
String input;
char[] answers = new char[numAnswers];
final int numAnswers = 20;
Scanner keyboard = new Scanner(System.in);
System.out.println("Please type the answer ");
for (int a = 0; a < answers.length; a++)
{
System.out.print("Question " + (a + 1) + ": ");
input = keyboard.nextLine();
answers[a] = input.charAt(0);
while (!valid(answers[a]))
{
System.out.println("ERROR: this is not a valid respose. Please answer with one of the following; A, B, C, or D.");
System.out.print("Question " + (a + 1) + ": ");
input = keyboard.nextLine();
answers[a] = input.charAt(0);
}
}
DriverExam exam = new DriverExam(answers());
Wrong = exam.questionsMissed()
System.out.println("Correct answers: " + exam.totalCorrect());
System.out.println("Incorrect answers: " + exam.totalIncorrect())
if (exam.passed())
System.out.println("Congratulations! You have Passed the Drivers Licence exam");
else
System.out.println("Sorry, You have not passed the Drivers Licene exam this time");
if (Wrong != null)
{
System.ot.println(" Here are the Questions you answered incorectly")
for (int a = 0; a < Wrong.length; a++)
System.out.println(Wrong[a] + " ");
}
}
public static boolean valid(char c)
{
boolean status;
if (c == 'A' || C == 'B' || c == 'C' || c== 'D')
status = true;
else
status = false;
return status;
}
}
-
May 16th, 2012, 07:04 AM
#2
Re: help! :)
Codeguru has a java section. Posting your question there will probably give you more answers.
-
May 16th, 2012, 07:11 AM
#3
Re: help! :)
And please using code tags while posting the code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|