🕡

10.6 Chapter 10 Project

 

Add Matrices

Adapted from Exercise 8.5, Introduction to Java Programming (Comprehensive) by Y. Daniel Liang, 10th ed.
Create a program called AddMatrices which adds two 3x3 matrices and prints the result. The program should prompt the user to enter data for 2 matrices and then displays those 2 matrices and the sum matrix. How do I add 2 matrices?
Example output:
Enter matrix1: 1 2 3 4 5 6 7 8 9 Enter matrix2: 0 2 4 1 4.5 2.2 1.1 4.3 5.2 The matrices are added as follows 1.0 2.0 3.0 0.0 2.0 4.0 1.0 4.0 7.0 4.0 5.0 6.0 + 1.0 4.5 2.2 = 5.0 9.5 8.2 7.0 8.0 9.0 1.1 4.3 2.2 8,1 12.3 14.2
💡
Hint: You may need to use the Double.parseDouble("a string") to convert the user input to doubles. Read more about that method.

Next Section

Ch. 10 Quiz
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.