Ex 8.5a, Ex. 8.5b, Ex. 8.5d
//***************************************************
// Ex. 8.5a
//***************************************************
public class ex8point5a {
public static void main(String[] args) {
String names[] = new String[25];
names[0] = "Michael Jordan";
names[1] = "Wilt Chamberlain";
names[2] = "Bill Russell";
names[3] = "Shaquille O'Neal";
names[4] = "Oscar Robertson";
names[5] = "Magic Johnson";
names[6] = "Kareem Abdul-Jabbar";
names[7] = "Tim Duncan";
names[8] = "Larry Bird";
names[9] = "Kobe Bryant";
names[10] = "Jerry West";
names[11] = "Elgin Baylor";
names[12] = "Hakeem Olajuwon";
names[13] = "Bob Pettit";
names[14] = "Moses Malone";
names[15] = "Julius Erving";
names[16] = "John Havlicek";
names[17] = "Karl Malone";
names[18] = "Isiah Thomas";
names[19] = "Charles Barkley";
names[20] = "Rick Barry";
names[21] = "John Stockton";
names[22] = "Elvin Hayes";
names[23] = "Bob Cousy";
names[24] = "David Robinson";
int size = names.length;
for (int i=0; i<size; i++)
{
System.out.println(names[i]);
}
}
}
//**************************************************************
// Ex. 8.5b
//**************************************************************
public class ex8point5b {
public static void main(String[] args) {
// TODO Auto-generated method stub
double grades[] = new double [41];
String names[] = new String[40];
names[0] = "Michael Jordan";
names[1] = "Wilt Chamberlain";
names[2] = "Bill Russell";
names[3] = "Shaquille O'Neal";
names[4] = "Oscar Robertson";
names[5] = "Magic Johnson";
names[6] = "Kareem Abdul-Jabbar";
names[7] = "Tim Duncan";
names[8] = "Larry Bird";
names[9] = "Kobe Bryant";
names[10] = "Jerry West";
names[11] = "Elgin Baylor";
names[12] = "Hakeem Olajuwon";
names[13] = "Bob Pettit";
names[14] = "Moses Malone";
names[15] = "Julius Erving";
names[16] = "John Havlicek";
names[17] = "Karl Malone";
names[18] = "Isiah Thomas";
names[19] = "Charles Barkley";
names[20] = "Rick Barry";
names[21] = "John Stockton";
names[22] = "Elvin Hayes";
names[23] = "Bob Cousy";
names[24] = "David Robinson";
names[25] = "II. Tim Duncan";
names[26] = "II. Larry Bird";
names[27] = "II. Kobe Bryant";
names[28] = "II. Jerry West";
names[29] = "II. Elgin Baylor";
names[30] = "II. Hakeem Olajuwon";
names[31] = "II. Bob Pettit";
names[32] = "II. Moses Malone";
names[33] = "II. Julius Erving";
names[34] = "II. John Havlicek";
names[35] = "II. Karl Malone";
names[36] = "II. Isiah Thomas";
names[37] = "II. Charles Barkley";
names[38] = "II. Rick Barry";
names[39] = "II. John Stockton";
grades[1] = 45;
grades[2] = 67;
grades[3] = 65;
grades[4] = 75;
grades[5] = 54;
grades[6] = 10;
grades[7] = 57;
grades[8] = 86;
grades[9] = 75;
grades[10] = 24;
grades[11] = 75;
grades[12] = 75;
grades[13] = 43;
grades[14] = 32;
grades[15] = 75;
grades[16] = 42;
grades[17] = 54;
grades[18] = 32;
grades[19] = 43;
grades[20] = 32;
grades[21] = 57;
grades[22] = 97;
grades[23] = 65;
grades[24] = 65;
grades[25] = 65;
grades[26] = 75;
grades[27] = 54;
grades[28] = 10;
grades[29] = 57;
grades[30] = 86;
grades[31] = 75;
grades[32] = 24;
grades[33] = 75;
grades[34] = 75;
grades[35] = 43;
grades[36] = 32;
grades[37] = 75;
grades[38] = 65;
grades[39] = 75;
grades[40] = 84;
int size = names.length;
int size1 = grades.length;
int i1 = 0;
for (int i=0 ; i<size && i1<size1 ; i++)
{
i1++;
{
System.out.println(names[i] + " " + grades[i1]);
}
}
}
}
//*******************************************************
// Ex. 8.5d
//*******************************************************
public class ex8point5d {
public static void main(String[ ] args)
{
int[][] scores = { {1, 36, 43, 54, 75, 78, 46, 33, 72},
{2, 82, 44, 73, 24, 83, 33, 62, 81},
{3, 33, 45, 54, 65, 75, 33, 52, 85},
{4, 61, 17, 71, 43, 81, 42, 51, 73},
{5, 53, 64, 85, 52, 71, 64, 33, 62},
{6, 32, 34, 53, 64, 73, 83, 92, 51},
{7, 43, 65, 64, 75, 85, 43, 22, 65},
{8, 61, 61, 51, 43, 31, 72, 51, 83},
{9, 53, 35, 44, 65, 85, 53, 32, 55},
{10, 61, 61, 81, 55, 41, 32, 21, 63}};
System.out.println("Student Grades");
for (int i = 0; i < scores.length; i++)
{
System.out.print(scores[ i ] [ 0 ] + ". Student : ");
for (int j = 1; j < scores[ i ].length; j++)
{
System.out.print(scores[ i ][ j ] + " ");
}
System.out.println( );
}
}
}
No comments:
Post a Comment