-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainprogram.java
175 lines (175 loc) · 5.89 KB
/
mainprogram.java
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
* Demonstration program
*/
import java.util.Scanner;
import java.util.Random;
public class SelectionDemonstrator
{
public static void main (String[]args)
{
/*
* Random portion
*/
System.out.println("This section shows purely random selection. A random 10-number string is generated and \n compared to the target value, 0123456789.");
Random schroedinger = new Random();
Scanner reader = new Scanner (System.in);
char cont = 'Y';
char contx = 'Y';
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int f = 0;
int g = 0;
int h = 0;
int i = 0;
int j = 0;
int ax = 0;
int bx = 0;
int cx = 0;
int dx = 0;
int ex = 0;
int fx = 0;
int gx = 0;
int hx = 0;
int ix = 0;
int jx = 0;
int countp = 0;
int countn = 0;
String contHolder = null;
while ((cont == 'Y')||(cont == 'y'))
{
a = (schroedinger.nextInt(10));
b = (schroedinger.nextInt(10));
c = (schroedinger.nextInt(10));
d = (schroedinger.nextInt(10));
e = (schroedinger.nextInt(10));
f = (schroedinger.nextInt(10));
g = (schroedinger.nextInt(10));
h = (schroedinger.nextInt(10));
i = (schroedinger.nextInt(10));
j = (schroedinger.nextInt(10));
countp++;
System.out.printf("%n%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%n",a,b,c,d,e,f,g,h,i,j);
if ((a == 0)&&(b == 1)&&(c == 2)&&(d == 3)&&(e == 4)&&(f == 5)&&(g == 6)&&(h == 7)&&(i == 8)&&(j == 9))
{
System.out.println("Target reached (a miracle has occurred, these chances are astronomically low) after " +countp + " attempts. Now proceeding to next part of demo.");
cont = 'N';
}
else
{
System.out.println("The numbers do not equal the target. " +countp + " attempts have been made so far. Do you wish to continue? Enter Y for yes, anything else for no.");
contHolder = reader.next();
cont = contHolder.charAt(0);
}
}
a = 0;
b = 0;
c = 0;
d = 0;
e = 0;
f = 0;
g = 0;
h = 0;
i = 0;
j = 0;
System.out.println("The next section will now simulate cumulative selection. Target is again 0123456789.");
while ((contx == 'y')||(contx == 'Y'))
{
if (ax == 0)
{
a = (schroedinger.nextInt(10));
}
if (bx == 0)
{
b = (schroedinger.nextInt(10));
}
if (cx == 0)
{
c = (schroedinger.nextInt(10));
}
if (dx == 0)
{
d = (schroedinger.nextInt(10));
}
if (ex == 0)
{
e = (schroedinger.nextInt(10));
}
if (fx == 0)
{
f = (schroedinger.nextInt(10));
}
if (gx == 0)
{
g = (schroedinger.nextInt(10));
}
if (hx == 0)
{
h = (schroedinger.nextInt(10));
}
if (ix == 0)
{
i = (schroedinger.nextInt(10));
}
if (jx == 0)
{
j = (schroedinger.nextInt(10));
}
if (a == 0)
{
ax = 3;
if (b == 1)
{
bx = 3;
if (c == 2)
{
cx = 3;
if (d == 3)
{
dx = 3;
if (e == 4)
{
ex = 3;
if (f == 5)
{
fx = 3;
if (g == 6)
{
gx = 3;
if (h == 7)
{
hx = 3;
if (i == 8)
{
ix = 3;
if (j == 9)
{
jx = 3;
}
}
}
}
}
}
}
}
}
}
System.out.printf("%n%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%n",a,b,c,d,e,f,g,h,i,j);
countn++;
if ((a == 0)&&(b == 1)&&(c == 2)&&(d == 3)&&(e == 4)&&(f == 5)&&(g == 6)&&(h == 7)&&(i == 8)&&(j == 9))
{
System.out.println("Target reached after " +countn + " attempts. Now proceeding to next part of demo.");
contx = 'N';
}
else
{
System.out.println("The numbers do not equal the target. " +countp + " attempts have been made so far. Do you wish to continue? Enter Y for yes, anything else for no.");
;contHolder = reader.next();
;contx = contHolder.charAt(0);
}
}
}
}