Laboratory Activity #10
Laboratory Activity #10
Source Code (screenshot):
Text-based Code:
package finalsactivities;
}
for(int column = 0; column < table[row].length; column++) {
value = (row * 50) + ((column + 1) * 5); //To get the next number depending on
the row and column
table[row][column] = value; //To hold the value computed
if (column == 0) {
System.out.printf("|"); //To put a line before each
value placed on the leftmost
}
System.out.printf("\s\s" + table[row][column] + "\t|"); //To display value and make it not
close to dividers
}
System.out.println("");
System.out.println("+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+"); //For enclosing
purposes as part of the design
}
System.out.println("|\t\t\t\t\t\t\t\t\t\t|");
for(int i= 0; i < table.length ; i++) {
for(int j = 0; j < table[i].length; j++) {
int i1 = (int)(Math.random() * table.length); //To pick any number from 0-9 for i1
int j1 = (int)(Math.random() * table[i].length); //To pick any number from 0-9 for j1
//To swap matrix [i][j] with matrix [i1][i1j]
int temporaryVal = table[i][j];
table[i][j] = table[i1][j1];
table[i1][j1] = temporaryVal;
}
}
System.out.println("+-------------------------------------------------------------------------------+");
System.out.println("|\t\t\s\s\s\s\s\s\sRANDOMIZED TABLE OF MULTIPLES OF 5\t\t\t|");
for(int row = 0; row < table.length ; row++) {
if (row == 0) {
System.out.printf("|_______________________________________________________________________________|\n"); //To
enclose the title
}
for(int column = 0; column < table[row].length; column++) {
if (column == 0) {
System.out.printf("|");
//To put a line before each value placed on the leftmost
}
System.out.printf("\s\s" + table[row][column] + "\t|"); //To
display value and make it not close to dividers
}
System.out.println("");
System.out.println("+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+"); //For enclosing
purposes as part of the design
}
System.out.println("|\t\t\t\t\t\t\t\t\t\t|");
System.out.println("+-------------------------------------------------------------------------------+");
System.out.println("|\t\t\t\s\s\sINDEX OF 50, 330, AND 450.\t\t\t\t|");
System.out.println("|_______________________________________________________________________________|");
System.out.println("|\t\t\t\t\t\t\t\t\t\t|");
}
Sample Output:
Source Code (screenshot):
Text-based Code:
package finalsactivities;
//To print label of student, their corresponding scores, and its percentage.
System.out.printf("|\sStudent %d: correct answers count is %d \t\s\s(%.2f %%)\t|\n", i,
scores[i], (double) scores[i] / answerKey.length * 100 );
}
System.out.println("|_______________________________________________________________|");
}
Sample Output:
” I affirm that I have not given or received any unauthorized help in this
assignment, and that this work is my own “