Okay, so I am trying to write a program which uses the Myers-Briggs personality test to turn this:
Snoopy
AABAAAAAAAAAAAABAAAABAAAAAAAAAAAABAAAABAAABABABAABAAAAAABAAAAAABAAAAAA
Charlie Brown
AAABBAABBABBBAABAAAABABABBAAAABABBBBABBBABAABABAABABAAABABAAABBAABABBB
Linus
AABBAABBBBBABAABBBBABABBABAAAABABBABABBAABAABABAABABBBBBBBAAAAAAABBBBB
Lucy
BABBAAABBBBAAABAAAAAABBBAABAAAAABBBAAABAAAAABABAAAABAABBBBAAABBAABABBB
Peppermint Patty
BBBBAAABBBBABBBAAAAAABBBAABAAAAABBBAAABAAAAABABAAAABAABBBBAAABBAABABBB
Into this:
Snoopy:
6A-4B 17A-3B 18A-2B 18A-2B
[40%, 15%, 10%, 10%] = ISTJ
Charlie Brown:
7A-3B 11A-9B 9A-11B 10A-10B
[30%, 45%, 55%, 50%] = ISFP
Linus:
6A-4B 7A-13B 8A-12B 11A-9B
[40%, 65%, 60%, 45%] = INFJ
Lucy:
5A-5B 11A-9B 14A-6B 11A-9B
[50%, 45%, 30%, 45%] = ESTJ
Peppermint Patty:
5A-5B 10A-10B 14A-6B 9A-11B
[50%, 50%, 30%, 55%] = ENTP

My code presently looks like this (sorry for the mess. I am presently not the cleanest of coders, as you will be able to tell):

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

public class MyersBriggs{

	public static final int Define = 0;
	public static final int SecondSet1 = 1; //to avoid magic numbers
	public static final int SecondSet2 = 2;
	public static final int ThirdSet1 = 3;
	public static final int ThirdSet2 = 4;
	public static final int FourthSet = 5;
	public static final int Test = 6; //check what category question falls into
	public static void main (String[] args){
		Scanner console = new Scanner (System.in);
		File f = getFile( console );
		processFile(f);		
	}
	public static File getFile( Scanner keyboard ) {
		System.out.print( "Enter name of file to be processed: " );
		String fileName = keyboard.nextLine();
		File f = new File( fileName );
		System.out.println();
		return f;
	}
	public static void processFile(File f)throws FileNotFoundException{
		Scanner input = new Scanner (f);
		while (input.hasNextLine()){
			int SnA = 0;
			int SnB = 0;
			String text = input.nextLine();
			while (( text.charAt(0) == "S")||(text.charAt(0) == "L")||(text.charAt(0) == "P")){
				text.nextLine();
			}
			int numberOfChar = text.length();
			int intro = 0; //subject is introverted
			int extro = 0; //subject is extroverted
			int sense = 0; //guided by senses
			int intui = 0; //guided by intuition
			int think = 0; //focus on thinking
			int feeli = 0; //focus on feeling
			int judge = 0; //prefer to judge
			int perce = 0; //guided by perception
			int i=0;
			for (i=0; i<numberOfChar; i++){
				//determine whether person chose introverted or extroverted
				if ((i==Define)||((i%Test==Define))){
					if (text.charAt(i)=="A"){
						intro++;
					}
					else {
						extro++;
					}
				}
				//determine whether person chose sense or intuition
				else if (((i-SecondSet1)==Define)||((i-SecondSet2)==Define)||((i-SecondSet1)%
							Test==Define)||((i-SecondSet2)%Test==Define)){ 
					if (text.charAt(i)=="A"){
						sense++;
					}
					else {
						intui++;
					}
				}
				else if((i-ThirdSet1==Define)||(i-ThirdSet2==Define)||((i-ThirdSet1)%Test==Define)
								||((i-ThirdSet2)%Test==Define)){
					if (text.charAt(i)=="A"){
						think++;
					}
					else {
						feeli++;
					}
				}
				else {
					if (text.charAt(i)=="A"){
						judge++;
					}
					else {
						perce++;
					}
				}
			}	
		}
	}
}

I am getting 8 errors, which look like this:
MyersBriggs.java:36: incomparable types: char and java.lang.String
while (( text.charAt(0) == "S")||(text.charAt(0) == "L")||(text.charAt(0) == "P")){
^
MyersBriggs.java:36: incomparable types: char and java.lang.String
while (( text.charAt(0) == "S")||(text.charAt(0) == "L")||(text.charAt(0) == "P")){
^
MyersBriggs.java:36: incomparable types: char and java.lang.String
while (( text.charAt(0) == "S")||(text.charAt(0) == "L")||(text.charAt(0) == "P")){
^
MyersBriggs.java:37: cannot find symbol
symbol : method nextLine()
location: class java.lang.String
text.nextLine();
^
MyersBriggs.java:52: incomparable types: char and java.lang.String
if (text.charAt(i)=="A"){
^
MyersBriggs.java:62: incomparable types: char and java.lang.String
if (text.charAt(i)=="A"){
^
MyersBriggs.java:71: incomparable types: char and java.lang.String
if (text.charAt(i)=="A"){
^
MyersBriggs.java:79: incomparable types: char and java.lang.String
if (text.charAt(i)=="A"){
^
8 errors
and when I try to run it, I get the message: No main methods, applets, or MILIets (or MIDlets. I can't tell) found in file.

Does anyone know of any way I can fix this? I've been racking my brain and testing possible fixes, but I have not come up with a solution.
(Sorry for the inordinately long post. I just wanted to provide as much information as possible)(I also apologize for not adding nearly as many comments in the code as I know I need)

Recommended Answers

All 2 Replies

Use single quotes ' instead of double quotes " around each letter.

Thank you. That clears up most of my present problems. I still have one error, though.

Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1516)
at MyersBriggs.processFile(MyersBriggs.java:37)
at MyersBriggs.main(MyersBriggs.java:21)

EDIT: Nevermind, I just figured it out myself. When I finally finish the code I will mark this as solved. I would rather not create a second thread if an additional issue came up. Sorry to anyone who comes here expecting a problem which needs solving.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.