CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: help! :)

  1. #1
    Join Date
    May 2012
    Posts
    0

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

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: help! :)

    Codeguru has a java section. Posting your question there will probably give you more answers.

  3. #3
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    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
  •  





Click Here to Expand Forum to Full Width

Featured