Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Start.java:22: error: cannot find symbol

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Start.java:22: error: cannot find symbol

    Can any one help me to resolve my below coding problem?

    Start.java:22: error: cannot find symbol
    result.DriverExam(ans);
    ^
    symbol: method DriverExam(char)
    location: variable result of type DriverExam[]




    import java.util.Scanner;
    import java.io.*;

    public class Start
    {//start of class
    public static void main(String[] args)
    {//start of main

    Scanner keyboard = new Scanner(System.in);

    DriverExam[] result = new DriverExam[20];

    char ans;
    String input;
    System.out.print("================================ ===============================");

    for (int q = 1; q < result.length; q++)
    {
    System.out.print("\nPlease answer from the options given (A, B, C, or D).");
    input = keyboard.nextLine();
    ans = input.charAt(0);
    result.DriverExam(ans);
    }

    System.out.print("The result of your exam :" + result.passed());
    System.out.print("The total no. of correct answers are: " + result.totalCorrect());
    System.out.print("The total no. of incorrect answers are: " + result.totalIncorrect());
    System.out.print("The total no. of missed answers are: " + result.questionMissed());


    }//end of main
    }//end of class

    public class DriverExam
    {//start of class
    private final int PASSING = 15;
    private char[] correct = {'X', 'B', 'D', 'A', 'A', 'C',
    'A', 'B', 'A', 'C', 'D',
    'B', 'C', 'D', 'A', 'D',
    'C', 'C', 'B', 'D', 'A'};

    private char[] student;
    private int[] missed;
    private int numCorrect = 0;
    private int numIncorrect = 0;

    public DriverExam(char[] s)
    {//Start of constructor
    student = new char[correct.length];

    for (int q = 1; q < student.length; q++)
    {//Start of for loop
    student[q] = s[q];
    }//End of for loop

    gradeExam();
    }//End of constructor

    private void gradeExam()
    {//Start of method
    for (int q = 1; q < correct.length; q++)
    {//Start of for loop
    if (student[q] == correct[q])
    numCorrect = numCorrect +1;
    else
    numIncorrect = numIncorrect +1;
    }//End of for loop

    if (numIncorrect > 0)
    makeMissedArray();
    }//End of method

    private void makeMissedArray()
    {//Start of method
    missed = new int[numIncorrect];
    int m = 0;

    for (int q = 1; q < correct.length; q++)
    {//Start of for loop
    if (student[q] != correct[q])
    {
    missed[m] = q;
    m = m + 1;
    }
    }//End of for loop
    }//End of method

    public boolean passed()
    {
    return (numCorrect >= PASSING);
    }

    public int totalCorrect()
    {
    return numCorrect;
    }

    public int totalIncorrect()
    {
    return numIncorrect;
    }

    public int[] questionsMissed()
    {//Start of method
    if(numIncorrect == 0)
    return null;

    int[] temp = new int[numIncorrect];

    for (int n = 0; n < missed.length; n++)
    temp[n] = missed[n];

    return temp;
    }//End of method

    }//end of class


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Start.java:22: error: cannot find symbol

    The code is using the wrong arg when it calls driverExam.
    The method is defined to take a char[]
    the call is using a char as arg.

    Either change the method to take a char
    or change the call to the method to pass a char[]

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Cannot find symbol error in my java code
    By haliza hadi in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 20th, 2013, 07:20 PM
  2. Error:Cannot find Symbol
    By Leonardo1143 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 13th, 2013, 06:40 PM
  3. [SOLVED] cannot find symbol error
    By Topflyt in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 5th, 2011, 08:57 AM
  4. error :cannot find symbol
    By iswan in forum AWT / Java Swing
    Replies: 1
    Last Post: October 1st, 2011, 08:26 AM
  5. Cannot find symbol error
    By AnuR in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 23rd, 2011, 02:50 PM

Tags for this Thread