Purchase Solution

Program to print Numbers in Java

Not what you're looking for?

Ask Custom Question

Write a Java application that prints out numbers 2, 4 and 6 in row 1, numbers 3, 5 and 7 in row 2, numbers 8, 10 and 12 in row 3 and numbers 9, 11 and 13 in row 4. There should be an underline followed by a row of numbers that adds the numbers in the respective columns. The program should print out the information as follows:

2 4 6
3 5 7
8 10 12
9 11 13
__________

22 30 38

Purchase this Solution

Solution Summary

This solution provides a detailed program to print numbers in rows and columns.

Solution Preview

1.public class PrintMatrix
2.{
3.
4. public static void main(String args[])
5. {
6. int[][] matrix = new int[4][3]; //matrix values
7. int sumCol0, sumCol1, sumCol2; //column sum variables
8.
9. //initialize sum values to 0
10. sumCol0 = 0;
11. sumCol1 = 0;
12. sumCol2 = 0;
13.
14. //Store row values
15. matrix[0][0] = 2;
16. matrix[0][1] = 4;
17. matrix[0][2] = 6;
18. matrix[1][0] = 3;
19. matrix[1][1] = 5;
20. ...

Purchase this Solution


Free BrainMass Quizzes
Architectural History

This quiz is intended to test the basics of History of Architecture- foundation for all architectural courses.