VL-Programmieren/VL06/Aufgabe02/Aufgabe02.java

41 lines
957 B
Java
Raw Normal View History

2024-05-08 10:45:59 +00:00
package VL06.Aufgabe02;
/**
* Vorlesung 6 / Aufgabe 2
*
* @author Sebastian Brosch
*/
class Aufgabe02 {
public static void main(String[] args) {
Matrix matrix1 = new Matrix(3, 2);
matrix1.setValue(0, 0, 5);
matrix1.setValue(1, 0, 4);
matrix1.setValue(2, 0, 8);
matrix1.setValue(0, 1, 7);
matrix1.setValue(1, 1, 3);
matrix1.setValue(2, 1, 9);
Matrix matrix2 = new Matrix(3, 2);
matrix2.setValue(0, 0, 9);
matrix2.setValue(1, 0, 3);
matrix2.setValue(2, 0, 4);
matrix2.setValue(0, 1, 8);
matrix2.setValue(1, 1, 6);
matrix2.setValue(2, 1, 3);
System.out.println("\nMatrix 1:");
matrix1.print();
System.out.println("\nMatrix 2:");
matrix2.print();
System.out.println("\nMatrix 1 nach Multiplikation mit 5:");
matrix1.multiply(5);
matrix1.print();
System.out.println("\nMatrix 1 nach Addition mit Matrix 2:");
matrix1.add(matrix2);
matrix1.print();
}
}