Skip to content

Commit 986b6ff

Browse files
Merge pull request #409 from krishvsoni/kvs-patch1
added attendance_percent.java
2 parents 5cf6343 + cb84b13 commit 986b6ff

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

attendance_percent.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.*;
2+
3+
public class AttendancePercentage {
4+
5+
public static void main(String[] args) {
6+
7+
// Create an array to store the attendance data
8+
int[] attendanceData = {1,1,1,0,1,1,1,1,1,1,0,0,1,1,1,0,1,1,1,0,1};
9+
10+
// Calculate the total number of classes attended
11+
int totalClassesAttended = 0;
12+
for (int attendance : attendanceData) {
13+
if (attendance == 1) {
14+
totalClassesAttended++;
15+
}
16+
}
17+
18+
// Calculate the attendance percentage
19+
double attendancePercentage = (double) totalClassesAttended / attendanceData.length * 100;
20+
21+
// Display the attendance percentage
22+
System.out.println("The attendance percentage is " + attendancePercentage + "%");
23+
}
24+
}

matrix_multiplication.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
public class MatrixMultiplication {
2+
public static void main(String[] args) {
3+
int[][] A = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
4+
int[][] B = {{9, 8, 7}, {6, 5, 4}, {3, 2, 1}};
5+
int[][] RES = new int[3][3];
6+
7+
// Perform matrix multiplication
8+
for (int i = 0; i < 3; i++) {
9+
for (int j = 0; j < 3; j++) {
10+
for (int k = 0; k < 3; k++) {
11+
RES[i][j] += A[i][k] * B[k][j];
12+
}
13+
}
14+
}
15+
16+
// Print the arrays
17+
System.out.println("Matrix A:");
18+
printMatrix(A);
19+
System.out.println("Matrix B:");
20+
printMatrix(B);
21+
System.out.println("Result Matrix (A * B):");
22+
printMatrix(RES);
23+
}
24+
25+
// Helper method to print a matrix
26+
public static void printMatrix(int[][] matrix) {
27+
for (int i = 0; i < matrix.length; i++) {
28+
for (int j = 0; j < matrix[i].length; j++) {
29+
System.out.print(matrix[i][j] + " ");
30+
}
31+
System.out.println();
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)