\Java
Class1.java
package javaTest; /** * Summary description for Class1. */ public class Class1 { public Class1() { // // TODO: Add Constructor Logic here // } /** @attribute System.STAThread() */ public static void main(String[] args) { // // TODO: Add code to start application here // MyClass my = new MyClass(); int[] testArr = {69,47,97,46,37,65,53,20,22,3}; int i; System.Console.Write("{"); for(i = 0; i < testArr.length; i++) { System.Console.Write(testArr[i]+","); } System.Console.Write("}"); my.rotateRight(testArr); System.Console.Write("{"); for(i = 0; i < testArr.length; i++) { System.Console.Write(testArr[i]+","); } System.Console.Write("}"); int testCpy[] = my.arrayCopy(my.makeIndexArray()); for(i = 0; i < 10; i++) System.Console.Write(testCpy[i]+"\n"); System.Console.Write("\n*****Begin Die******\n\n"); for (int k=0; k<10; k++) { Die die = new Die(6); for (i=0; i < 10; i++) System.out.print(die.roll() + " "); System.out.println(); } System.Console.Write("\n*****Rolling 2000 Times******\n\n"); int[] rollArray = new int[7]; for(i = 0; i < 7; i++) rollArray[i] = 0; Die die = new Die(6); int j; for(i = 0; i < 2000; i++) { j = die.roll(); rollArray[j]++; } int Total = 0; for(i = 1; i < 7; i++) { Total += rollArray[i]; System.Console.Write("Number '"+i+"': "+rollArray[i]+"\n"); } System.Console.Write("Total: "+Total+"\n"); return; } } public class Die { private int dieSides; static System.Random rand = new System.Random(); /* Constructor */ public Die() { this.dieSides = 6; } public Die(int iSides) { this.dieSides = iSides; } /* roll The die */ public int roll() { return rand.Next(dieSides) + 1; } } public class MyClass { public boolean divides(int b, int a) { if(a == 0) return false; if((a % b) == 0) return true; else return false; } public void upByThrees(int n) { int i; for(i = 0; i < n; i++) { System.out.println(((i * 3)+1)); } } public int lastZero(int[] data) { int i; for(i = data.length; i >= 0; i--) { if(data[i] == 0) return i; } return -1; } public int longString(String[] data) { int i; int counter = 0; for(i = 0; i < data.length; i++) { if(data[i].length() > 10) counter++; } return counter; } public int trueCount(boolean[] data) { int iTrue = 0; for(int i = 0; i < data.length; i++) { if(data[i]) iTrue++; } return iTrue; } public int[] makeIndexArray() { int myArr[] = new int[10]; int i; for(i = 0; i < 10; i++) myArr[i] = i; return myArr; } public int[] arrayCopy(int[] theArray) { int copyArr[] = new int[theArray.length]; int i; for(i = 0; i < theArray.length; i++) copyArr[i] = theArray[i]; return copyArr; } public double getElementValue(int index, double [ ] theArray) { if(index < 0 || index > theArray.length) return -1.0; return theArray[index]; } public void rotateRight(int[] theArray) { int i; int[] holdArray = new int[theArray.length]; for(i = 0; i < holdArray.length; i++) holdArray[i] = theArray[i]; for(i = 1; i < holdArray.length + 1; i++) { theArray[(i % theArray.length)] = holdArray[i - 1]; } } public boolean mirrorImage(int[] data1, int[] data2) { int i; for(i = 0; i < data1.length; i++) { if(data1[i] != data2[data1.length - (i + 1)]) return false; } return true; } }