package Set_two;public class q1_7_2 { public static void main(String[] args) { int[] array; array = new int[10]; System.out.printf("%s%8s\n", "Index","Value"); for(int i =0; i<array.length; i++) System.out.printf("%s%8d\n", i,array[i]); }}package Set_two;public class q1_7_3 { public static void main(String[] args) { int[] array = { 32, 27, 64, 18, 95, 14, 90, 70, 60, 37 }; System.out.printf("%s%8s\n", "Index","Value"); for(int i =0; i<array.length; i++) System.out.printf("%s%8d\n", i+1,array[i]); }}package Set_two;public class q1_7_5 { public static void main(String[] args){ int[] array = { 87, 68, 94, 100, 83, 78, 85, 91, 76, 87 }; int total = 0; for(int i = 0; i< array.length; i++) { if(i==array.length-1) System.out.printf("%d = ",array[i]); else System.out.printf("%d + ",array[i]); total+=array[i]; } System.out.println(total); }}package Set_two;public class q1_7_6 { public static void main(String[] args){ int[] array = { 0, 0, 0, 0, 0, 0, 1, 2, 4, 2, 1 }; System.out.println("Grade distribution : "); for(int i = 0; i<array.length; i++) { if(i==10) System.out.printf("%5d:", 100); else System.out.printf("%02d-%02d:", i*10, i*10+9); for(int j = 0; j<array[i]; j++) System.out.print("*"); System.out.println(); } }}package Set_two;import java.util.Random;public class q1_7_7 { public static void main(String[] args){ Random x = new Random(); int[] a = new int[7]; for(int i = 1; i <= 6000000; i++) ++a[1+x.nextInt(6)]; System.out.printf( "%s%10s\n", "Face", "Frequency" ); for(int j =1; j<a.length; j++){ System.out.printf( "%4d%10d\n", j, a[ j ] ); } }}Part 1 : GradeBook.javapackage Set_two;public class GradeBook {String cn;int[] g;float total = 0;int min = 999;int max = -1;public GradeBook(String name, int[] a){ cn = name; g = a;}public void setcn(String name){ cn = name;}public String getcn(){ return cn;}public void displayMessage(){ System.out.printf("Welcome to the gradebook for %s\n\n",getcn());}public void processGrades(){ System.out.println("The grade is : \n\n"); for(int i = 0; i<g.length; i++){ System.out.printf("Student %d: %d\n",i+1,g[i]); total += g[i]; } System.out.printf("\nClass avarage : %2.2f\n", getaverage()); System.out.printf("Lowest Grade : %d\n", getlow()); System.out.printf("Highest Grade : %d\n", gethigh());}private float getaverage() { return total/g.length;}private int gethigh() { for(int i = 0; i<g.length; i++){ if(max<g[i]) max = g[i]; } return max;}private int getlow() { for(int i = 0; i<g.length; i++) { if(min>g[i]) min = g[i]; } return min;}}Part 2 : Mainfunctionpackage Set_two;public class q1_7_14 { public static void main( String[] args ){ int[] gradesArray = { 87, 68, 94, 100, 83, 78, 85, 91, 76, 87 }; GradeBook myGradeBook = new GradeBook("CS101 Introduction to Java Programming",gradesArray ); myGradeBook.displayMessage(); myGradeBook.processGrades(); }}package Set_two;public class q1_7_17 { public static void main( String[] args ) { int[][] array1 = { { 1, 2, 3 }, { 4, 5, 6 } }; int[][] array2 = { { 1, 2 }, { 3 }, { 4, 5, 6 } }; System.out.println( "Values in array1 by row are" ); outputArray( array1 ); System.out.println( "\nValues in array2 by row are" ); outputArray( array2 ); } public static void outputArray(int[][] array ){ for ( int row = 0; row < array.length; row++ ) { for ( int column = 0; column < array[ row ].length; column++ ) System.out.printf( "%d ", array[ row ][ column ] ); System.out.println(); } }}Source :