Last active
August 11, 2021 16:40
-
-
Save lukes5/c0ee25178b57d13f59ab0bbff04741f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
public class Personality { | |
public static void main(String[] args) throws FileNotFoundException { | |
intro(); | |
Scanner console = new Scanner(System.in); | |
System.out.print("input file name? "); | |
String inputFileName = console.next(); | |
// System.out.print("output file name? "); | |
// String outputFileName = console.next(); | |
Scanner input = new Scanner(new File(inputFileName)); | |
scanLine(input); | |
} | |
public static void intro() { | |
System.out.println("This program processes a file of answers to the"); | |
System.out.println("Keirsey Temperament Sorter. It converts the"); | |
System.out.println("various A and B answers for each person into"); | |
System.out.println("a sequence of B-percentages and then into a"); | |
System.out.println("four-letter personality type."); | |
System.out.println(); | |
} | |
public static void scanLine(Scanner input) { | |
// int[] aCount = new int[4]; | |
// int[] bCount = new int[4]; | |
while (input.hasNextLine()) { | |
System.out.print(input.nextLine()); | |
String test = input.nextLine(); | |
test = test.toLowerCase(); | |
// for (int i = 0; i < 70; i++) { | |
// if (i % 7 == 0) { | |
// if (test.charAt(i) == 'a') { | |
// | |
// } else if (test.charAt(i) == 'b'){ | |
// | |
// } | |
// } | |
// } | |
char[] testArray = new char[70]; | |
for(int i = 0; i < 70; i++) { | |
testArray[i] = test.charAt(i); | |
} | |
int[] aCount = scanLineCount(testArray, 'a'); | |
int[] bCount = scanLineCount(testArray, 'b'); | |
System.out.println(Arrays.toString(aCount)); | |
System.out.println(Arrays.toString(bCount)); | |
} | |
} | |
public static int[] scanLineCount(char[] testArray, char a) { | |
int[] count = new int [4]; | |
for (int i = 0; i < 4; i++) { | |
for (int j = 1; j < 70; j += 7) { | |
if (testArray[j] == a) { | |
count[i]++; | |
} | |
} | |
} | |
// for (int i = 0; i < 70; i++) { | |
// for (int j = 0; j < 4; j++) { | |
// if (testArray[(i + j) % 7 ] == a) { | |
// count[j]++; | |
// } else if (testArray[(i + j) % 7] == 'b') { | |
// | |
// } | |
// } | |
// } | |
return count; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Betty Boop | |
BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABAAAAAA | |
Snoopy | |
AABBAABBBBBABABAAAAABABBAABBAAAABBBAAABAABAABABAAAABAABBBBAAABBAABABBB | |
Bugs Bunny | |
aabaabbabbbaaaabaaaabaaaaababbbaabaaaabaabbbbabaaaabaabaaaaaabbaaaaabb | |
Daffy Duck | |
BAAAAA-BAAAABABAAAAAABA-AAAABABAAAABAABAA-BAAABAABAAAAAABA-BAAABA-BAAA | |
The frumious bandersnatch | |
-BBaBAA-BBbBBABBBBA-BaBBBBBbbBBABBBBBBABB-BBBaBBABBBBBBB-BABBBBBBBBBBB | |
Minnie Mouse | |
BABA-AABABBBAABAABA-ABABAAAB-ABAAAAAA-AAAABAAABAAABAAAAAB-ABBAAAAAAAAA | |
Luke Skywalker | |
bbbaaabbbbaaba-BAAAABBABBAAABBAABAAB-AAAAABBBABAABABA-ABBBABBABAA-AAAA | |
Han Solo | |
BA-ABABBB-bbbaababaaaabbaaabbaaabbabABBAAABABBAAABABAAAABBABAAABBABAAB | |
Princess Leia | |
BABBAAABBBBAAABBA-AAAABABBABBABBAAABAABAAABBBA-AABAABAAAABAAAAABABBBAA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
My name is Jonathan and I work with the introductory computer science courses at the University of Washington. This post contains solution code to our Personality Test homework assignment.
This post's code is indexed by Google, enabling our current students to easily find it and cheat on their assignments.
Would you please remove this post or make it secret in order to help us enforce our academic policy?
By removing this post, you would be removing a tool that our students could use in academic misconduct.
Thank you,
Jonathan Sanders Intro Support,
Computer Science & Engineering University of Washington
jsanders@cs.washington.edu
More info on our course: http://courses.cs.washington.edu/courses/cse142/15au/