10 for(int i
= 99; i
>95; i
--){
11 cout
<< i
<< " bottles of rootbeer on the wall" << endl
;
12 cout
<< i
<< " bottles of rootbeer" << endl
;
13 cout
<< "Take one down and pass it around" << endl
;
14 cout
<< "One less bottle of rootbeer on the wall" << endl
<< endl
;
22 for (A
=1; A
< 10; A
++)
24 for (B
=1; B
<= A
; B
++)
33 for(int i
=1; i
< 10; i
++){
34 for(int j
=0; j
< i
; j
++){
43 for (int X
=0;X
<10;X
++)
45 for (int R
=0;R
<(9-X
);R
++)
49 for(int D
=0; D
<X
; D
++)
59 for(int i
=1; i
<= lines
; i
++){
60 for(int j
=0; j
< (lines
-i
); j
++) cout
<< " ";
61 for(int j
=1; j
< i
; j
++) cout
<< "0";
63 for(int j
=1; j
< i
; j
++) cout
<< "0";
70 for (int X
=0;X
<10;X
++)
72 for (int R
=0;R
<(9-X
);R
++)
76 for(int D
=0; D
<X
; D
++)
80 for(int E
=0;E
<(X
-1);E
++)
88 for(int D
=0;D
<(11-X
);D
++)
92 for(int R
=0;R
<(X
-3);R
++)
96 for(int E
=0;E
<(X
-2);E
++)
105 vector
<int> input (5);
109 for(int i
=0;i
<5;i
++){
110 cout
<< "Please input a number: ";
114 avg
= float(tot
)/5.0;
116 cout
<< "The average is " << avg
<< endl
<< endl
;
117 cout
<< "The following are greater than the average: " << endl
;
118 for(int i
=0; i
<5; i
++){
119 if(input
[i
]>avg
) cout
<< input
[i
] << endl
;
124 vector
<int> input (10);
128 for(int i
=0;i
<10;i
++){
129 cout
<< "Please input a number: ";
132 cout
<< "Please input target value: ";
135 for(int i
=0;i
<10;i
++){
136 if(input
[i
] = target
) count
++;
139 cout
<< "The target value appears " << count
<< " times in the array";
144 int arrayPosi
[9]={0}, Position
, HitorMiss
, Bat
, n
, Leave
;
145 double BatAvrg
, arrayBat
[9]={0};
156 Position
= arrayPosi
[n
];
157 cout
<<"For Position " << n
+1 << ", input a 1 for a hit and a 0 for a miss.";
159 arrayBat
[n
] = HitorMiss
+arrayBat
[n
];
162 cout
<< "Done? Input 0 To Input Another Set, Input -1 To Exit. ";
167 BatAvrg
= arrayBat
[n
]/Bat
;
168 cout
<< "Position " << n
+1 << " batting average is " << BatAvrg
<< "" << endl
;
173 vector
<int> atBats(9);
175 vector
<int> bases(9);
181 cout
<< "Position: ";
197 cout
<< "The batting average for each position was: " << endl
;
198 for(int i
= 0; i
< 9; i
++){
199 cout
<< "Position " << i
+1 << " batting average is " << float(hits
[i
])/float(atBats
[i
]) << endl
;
201 cout
<< endl
<< "The slugging percentage for each position was: " << endl
;
202 for(int i
= 0; i
< 9; i
++){
203 cout
<< "Position " << i
+1 << " slugging percentage is " << float(bases
[i
])/float(atBats
[i
]) << endl
;
210 double D
=0,B
=0,N
=0,I
=0;
216 cout
<<"How many rolls of the dice? ";
223 T
=D
+B
-2;//-2 so that the number 2 will match with array slot 0
224 Total
[T
]++;//to increase the count of the slot matching the number
226 for(int C
=0;C
<11;C
++)
229 // cout<<Total[C]<<" "<<N<<" "<<R<<endl;// for debugging
230 cout
<<"The number "<<C
+2<<" was rolled "<<Total
[C
]<<" times or "<<R
<<" percent of the time"<<endl
;
235 vector
<string
> usr(10);
236 vector
<string
> pass(10);
237 string inputuser
, inputpass
;
238 bool complete
= false;
241 for(int i
=0;i
<10;i
++){
242 cout
<< "Please enter a username: ";
244 cout
<< "Please enter a password for " << usr
[i
] << ": ";
251 cout
<< "Please enter your username: ";
253 for(int i
=0;i
<10;i
++){
254 if(usr
[i
] == inputuser
){
260 cout
<< "Please enter your password: ";
263 if(pass
[pos
] == inputpass
){
264 cout
<< "Access Granted" << endl
;
268 cout
<< "Username and password do not match" << endl
<< endl
;
272 cout
<< "Username not found" << endl
<< endl
;
278 vector
<int> scores(6);
282 for(int i
= 0; i
< 6; i
++){
283 cout
<< "Input score: ";
289 for(int i
=0; i
< 5; i
++){
290 if(scores
[i
] > scores
[i
+1]){
292 scores
[i
] = scores
[i
+1];
298 for(int i
=1; i
< 5; i
++) tot
+=scores
[i
];
300 cout
<< "Highest score : " << scores
[5] << endl
;
301 cout
<< "Lowest score : " << scores
[0] << endl
;
302 cout
<< "Olympic Average : " << float(tot
)/4.0 << endl
;
308 cout
<< "Please select the program you would like to run:" << endl
;
309 cout
<< "\t" << "1. Ch.4 PE 2" << endl
;
310 cout
<< "\t" << "2. Ch.4 PE 4" << endl
;
311 cout
<< "\t" << "3. Ch.4 PE 5" << endl
;
312 cout
<< "\t" << "4. Ch.4 PE 6" << endl
;
313 cout
<< "\t" << "5. Ch.4 PE 7" << endl
;
314 cout
<< "\t" << "6. Ch.4 PE 8" << endl
;
315 cout
<< "\t" << "7. Ch.5 PE 2" << endl
;
316 cout
<< "\t" << "8. Ch.5 PE 4" << endl
;
317 cout
<< "\t" << "9. Ch.5 PE 5" << endl
;
318 cout
<< "\t" << "10. Ch.5 PE 6" << endl
;
319 cout
<< "\t" << "11. Ch.5 PE 7" << endl
;
320 cout
<< "\t" << "12. Ch.5 PE 8" << endl
;
321 cout
<< endl
<< "#: ";
364 cout
<< "Sorry, option unimplemented!";
368 char dontend
; cin
>> dontend
;