A program I wrote to help my girlfriend at the time with something.
read more
public class permutationsForAli {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int val = 0;
double totalnum = 0;
int alison = 0;
int drew = 0;
int fivehundreds = 0;
int hundreds =0;
int fifties =0;
int twenties =0;
int tens =0;
int zeros =0;
for (int x = 1; x < 21; x++) {
for (int y = 1; y < 21; y++) {
if (y < x) {
} else {
for (int z = 1; z < 21; z++) {
System.out.print(x + ",");
System.out.print(y + ",");
System.out.print(z);
if (1 <= z && z <= 4) {
val = 10;
}
if (5 <= z && z <= 10) {
val = 20;
}
if (11 <= z && z <= 15) {
val = 50;
}
if (16 <= z && z <= 19) {
val = 100;
}
if (z== 20) {
val = 500;
}
if (z < y) {
val = 0;
}
switch(val){
case 0: zeros++; break;
case 10: tens++; break;
case 20: twenties++; break;
case 50: fifties++; break;
case 100: hundreds++; break;
case 500: fivehundreds++; break;
}
System.out.print(" -" + val);
System.out.println();
totalnum++;
}
}
}
}
for (int a = 1; a < 21; a++) {
for (int b = 1; b < 21; b++) {
System.out.print(a + ",");
System.out.print(b);
if(b>=a){
if (1 <= b && b <= 4) {
val = 10;
}
if (5 <= b && b <= 10) {
val = 20;
}
if (11<= b && b <= 15) {
val = 50;
}
if (16 <= b && b <= 19) {
val = 100;
}
if (b== 20) {
val = 500;
}
switch(val){
case 10: tens++; break;
case 20: twenties++; break;
case 50: fifties++; break;
case 100: hundreds++; break;
case 500: fivehundreds++; break;
}
System.out.print(" -" + val);
System.out.println();
totalnum++;
}
else {
val = 0;
zeros++;
totalnum++;
System.out.print(" -" + val);
System.out.println();
}
drew+=val;
if (val != 0) {
alison++;
}
}
}
for (int c = 1; c < 21; c++) {
if (1 <= c && c <= 4) {
val = 10;
}
if (5 <= c && c <= 10) {
val = 20;
}
if (11 <= c && c <= 15) {
val = 50;
}
if (16 <= c && c <= 19) {
val = 100;
}
if (c== 20) {
val = 500;
}
switch(val){
case 0: zeros++; break;
case 10: tens++; break;
case 20: twenties++; break;
case 50: fifties++; break;
case 100: hundreds++; break;
case 500: fivehundreds++; break;
}
System.out.print(c);
System.out.print(" -" + val);
System.out.println();
totalnum++;
}
System.out.println(fivehundreds);
System.out.println(zeros+tens+twenties+fifties+hundreds+fivehundreds);
System.out.println(((500*(fivehundreds/totalnum))+(100*(hundreds/totalnum))+(50*(fifties/totalnum))+(20*(twenties/totalnum))+(10*(tens/totalnum))));
}}