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 9 of 9

Thread: Personality Test Grader Help

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

    Default Personality Test Grader Help

    Hi. I am supposed to make a computer program that is designed to grade the classic myersBriggs test. There is a text file that i have to import the information from and then use it to determine the personailty with four dimensions. I am having major issues with this problem. Any help would be appriciated.

    public class MyersBrigg
    {		
    	private static int JP = 0;
    	private static int TF = 0;
    	private static int SN = 0;
    	private static int IE = 0;
    	public static String[][] answers;
     
    public String[][] getArray() throws IOException
    {	
    	// Open the file
    	PrintWriter outputFile = new PrintWriter("C:/MB.txt");
     
    	// Write the array elements to the file
    	for (int row = 0; row < answers.length; row++)
    	{
    		for (int col = 0; col < answers[row].length; col++)
    			outputFile.println(answers[row][col]);
    	}
     
    	// Close the file
    	outputFile.close();
     
    	return answers;
    }
     
    public void getAnswers()
    {
    	int row = 1;
     
    	if ( row < answers.length);
    	{
    		int col = 0;
     
    		if ( col < answers[row].length);
    		{
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				IE++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				SN++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				SN++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				TF++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				TF++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				JP++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				JP++;
    				col++;
    			}
     
    		}
    	}
    	row += 2;
    }
     
     
    public static String[] getPersonality(String answer)
    {
     
    	// Create String Array object
    	String[] personality = new String[4];
     
    		if (IE < 4)
    			personality[0] = "I";
    		else 
    			personality[0] = "E";
     
    		if (SN < 5)
    			personality[1] = "S";
    		else 
    			personality[1] = "N";
     
    		if (TF < 5)
    			personality[2] = "T";
    		else
    			personality[2] = "F";
     
    		if (JP < 5)
    			personality[3] = "J";
    		else
    			personality[3] = "P";
     
    		return personality;
    }	
    public static String printAnswers(String answer)
    {
    	int A_IE = 20 - IE;
    	int A_SN = 20 - SN;
    	int A_JP = 20 - JP; 
    	int A_TF = 20 - TF;
     
        String answers = A_IE + "A-" + IE +"B " + A_SN +"A-" + SN +"B " 
        		+ A_JP + "A-" + JP + "B " + A_TF + "A-" + TF + "B";
     
    	return answers;
    }
    public static String printPercents(String answer)
    {
        String percents = "[" + IE/10 + ", " + SN/20 + ", " + JP/20 + ", " + TF/20 + "]";
     
        return percents;
    }
    }
     
     
    and my main class is as follows
     
    public class TestResults
    {
    	public static void main(String[] answer)
    	{
    		int row = 0;
    		int col = 0;
     
    		for (row = 0; row < MyersBrigg.answers.length; row++);
    		{
    			for (col = 0; col < MyersBrigg.answers[row].length; col++)
    				System.out.println(MyersBrigg.answers[row][col]);
     
    				row++;
    				System.out.println(MyersBrigg.printAnswers(MyersBrigg.answers[row][col]));
    				System.out.println(MyersBrigg.printPercents(MyersBrigg.answers[row][col]) +
    						MyersBrigg.getPersonality(MyersBrigg.answers[row][col]));			
    		}
    		System.out.println("There are no more test to score!");
    	}
    }

    I am fairly new to this. and am getting an error in my main thread. first it was a nullPointerException. and then a no method error. Now i am gettin this
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at TestResults.main(TestResults.java:13)

    Please help me guys!

    JV


  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: Personality Test Grader Help

    Please post the full text of the error messages. It will show what line the error happened on.

    What error are you getting on line 13?

    Do you get compiler errors? Please post them.
    Last edited by Norm; November 28th, 2012 at 07:31 PM. Reason: removed duplicate message
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Personality Test Grader Help

    Yes i am getting compliation errors. heres what the console in eclipse says.

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at TestResults.main(TestResults.java:13)

    which I believe is the line that is the main

    public static void main(string[] args)

    --- Update ---

    Yes i am getting compliation errors. heres what the console in eclipse says.

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at TestResults.main(TestResults.java:13)

    which I believe is the line that is the main

    public static void main(string[] args)

  4. #4
    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: Personality Test Grader Help

    Those are messages from your IDE. They don't say what is wrong.
    Can you get the errors from the compiler that explain what is wrong with the source of your program?

    Please Edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.

    The line you posted showing the error is NOT in the code you posted:
    public static void main(string[] args)
    The posted code has String not string.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Personality Test Grader Help

    /**
     * This program uses the MyersBriggs class
     * to read test scores from a file and get
     * their averages.
     * 
     * @author JVninja
     * @version 1.0
     * @date 11/26/12
     */
     
    public class TestResults
    {
    	public static void main(String[] arg)
    	{
     
    		int row = 0;
    		int col = 0;
     
    		for (row = 0; row < MyersBrigg.answers.length; row++);
    		{
    			for (col = 0; col < MyersBrigg.answers[row].length; col++)
    				System.out.println(MyersBrigg.answers[row][col]);
     
    				row++;
    				System.out.println(MyersBrigg.printAnswers(MyersBrigg.answers[row][col]));
    				System.out.println(MyersBrigg.printPercents(MyersBrigg.answers[row][col]) +
    						MyersBrigg.getPersonality(MyersBrigg.answers[row][col]));			
    		}
    		System.out.println("There are no more test to score!");
    	}
    }

    import java.io.*;
     
    /**
     * This program scores the classic Myer's
     * Brigg's personality test which consist of 
     * four personality dimensions and seventy 
     * questions with answers 'A' or 'B'.
     * 
     * @author Justin M. Veit
     * @version 1.0
     * @Date 11/26/12
     */
     
    public class MyersBrigg
    {		
    	private static int JP = 0;
    	private static int TF = 0;
    	private static int SN = 0;
    	private static int IE = 0;
    	public static String[][] answers;
     
    public String[][] getArray() throws IOException
    {	
    	// Open the file
    	PrintWriter outputFile = new PrintWriter("C:/User/JVninja/Desktop/Justin/MB.txt");
     
    	// Write the array elements to the file
    	for (int row = 0; row < answers.length; row++)
    	{
    		for (int col = 0; col < answers[row].length; col++)
    			outputFile.println(answers[row][col]);
    	}
     
    	// Close the file
    	outputFile.close();
     
    	return answers;
    }
     
    public void getAnswers()
    {
    	int row = 1;
     
    	if ( row < answers.length);
    	{
    		int col = 0;
     
    		if ( col < answers[row].length);
    		{
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				IE++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				SN++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				SN++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				TF++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				TF++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				JP++;
    				col++;
    			}
     
    			if (answers[row][col].equalsIgnoreCase("B"))
    			{	
    				JP++;
    				col++;
    			}
     
    		}
    	}
    	row += 2;
    }
     
     
    public static String[] getPersonality(String answer)
    {
     
    	// Create String Array object
    	String[] personality = new String[4];
     
    		if (IE < 4)
    			personality[0] = "I";
    		else 
    			personality[0] = "E";
     
    		if (SN < 5)
    			personality[1] = "S";
    		else 
    			personality[1] = "N";
     
    		if (TF < 5)
    			personality[2] = "T";
    		else
    			personality[2] = "F";
     
    		if (JP < 5)
    			personality[3] = "J";
    		else
    			personality[3] = "P";
     
    		return personality;
    }	
    public static String printAnswers(String answer)
    {
    	int A_IE = 20 - IE;
    	int A_SN = 20 - SN;
    	int A_JP = 20 - JP; 
    	int A_TF = 20 - TF;
     
        String answers = A_IE + "A-" + IE +"B " + A_SN +"A-" + SN +"B " 
        		+ A_JP + "A-" + JP + "B " + A_TF + "A-" + TF + "B";
     
    	return answers;
    }
    public static String printPercents(String answer)
    {
        String percents = "[" + IE/10 + ", " + SN/20 + ", " + JP/20 + ", " + TF/20 + "]";
     
        return percents;
    }
    }
    }

    I hope this works. and makes it look more correct with line numbers. i tried using the format you suggested. I am VERY new to this. and I am unaware of how to find the errors from the compiler. Within eclipse there says there are no errors on the left when typing the code, but it just wont run correctly.

    Thanks in advance for any help!

  6. #6
    Junior Member
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Personality Test Grader Help

    How do I see the compiler errors. sorry I am very new to this. and cant figure out how to find that.

  7. #7
    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: Personality Test Grader Help

    How do I see the compiler errors.
    That's a problem with using an IDE. They hide or sometimes do not even display a list of error messages. That's why lots of us recommend beginners start with an editor and use the javac and java commands in a command prompt window. Any error messages are displayed in the command prompt window.

    I guess you need to study how to use your IDE so you can get it to tell you what the "COMPILER" errors are.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Personality Test Grader Help

    I am using eclipse and if you mean the problems it displays next to the javadoc and console there are no warnings or errors. no syntax errors. nothings I can see. but thanks for the help anyways. I will do what I can to figure things out ..

  9. #9
    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: Personality Test Grader Help

    There is a section of the forum for IDEs. Try asking there about how to get the compiler's error messages displayed so they can be copied to the forum.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Test Cpu and Thread
    By megaoverclock in forum Threads
    Replies: 0
    Last Post: August 25th, 2011, 04:37 AM
  2. How to test all files in a folder
    By GodspeedPR in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 28th, 2011, 06:15 AM
  3. Polymorphism test
    By speedycerv in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 29th, 2011, 07:15 AM
  4. JUnit test for ER
    By raphytaffy in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 20th, 2010, 09:26 PM
  5. A simple test for you all
    By Maximillian in forum The Cafe
    Replies: 6
    Last Post: December 2nd, 2009, 04:15 PM