-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamRandomAnswer.java
More file actions
94 lines (72 loc) · 2.68 KB
/
Copy pathExamRandomAnswer.java
File metadata and controls
94 lines (72 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import java.util.Random;
//-------------------------------------------------------
// Francisco Rogel February 12, 2016
//
// Program to see if answering straight down on
// a test actually works better than randomly
//-------------------------------------------------------
public class ExamRandomAnswer
{
static int numberOFOptions = 4;
static int[] questionArray = new int[numberOFOptions];
static Random rand = new Random();
public static void main(String[] args)
{
int[] questionArray = new int[numberOFOptions];
final int totalQuestions = 100000;
int countForSameAnswer = 0; // also like choosing only A
int countForRandomPick = 0;
int countLetterB = 0;
int countLetterC = 0;
int countLetterD = 0;
int randomPick = 0;
int randomIndex = 0;
double ratio = 0;
for(int i = 0; i < totalQuestions; i++)
{
randomIndex = rand.nextInt(4);
questionArray[randomIndex] = 1;
printArray(questionArray);
randomPick = rand.nextInt(4); // between 0 and 3 (0,1,2,3)
if(questionArray[randomPick] ==1)
countForRandomPick++;
if(questionArray[0] == 1 ) //A
countForSameAnswer++;
if (questionArray[1] == 1) // B
countLetterB++;
if (questionArray[2] == 1) // C
countLetterC++;
if (questionArray[3] == 1) // D
countLetterD++;
for (int j = 0; j < questionArray.length; j++)
{
questionArray[j] = 0;
}
}
ratio = ((double)countForSameAnswer/(double)totalQuestions);
System.out.println();
System.out.println("Pseudo multiple choice test that runs " + totalQuestions + " times."); //
System.out.println();
System.out.println("The total number or correct answers if you guess randomly: " + countForRandomPick);
System.out.println("The ratio of guessing: " + ((double)countForRandomPick/(double)totalQuestions));
System.out.println();
System.out.println("The total number correct when A is put straight down: " + countForSameAnswer);
System.out.println("The ratio of only A answer: " + ratio);
System.out.println();
System.out.println("The total number of correct answers that were B: " + countLetterB);
System.out.println();
System.out.println("The total number of correct answers that were C: " + countLetterC);
System.out.println();
System.out.println("The total number of correct answers that were D: " + countLetterD);
System.out.println();
System.out.println("Adding all correct answers to prove that there were " + totalQuestions + " questions: " + (countForSameAnswer + countLetterB + countLetterC + countLetterD));
}
private static void printArray(int[] array)
{
for(int i = 0; i < array.length; i++)
{
System.out.print(array[i] + " "); // Calculators asked for
}
System.out.println();
}
}