fork download
  1.  
  2. import java.util.Scanner;
  3.  
  4. /**
  5.  *
  6.  * ColumnSum
  7.  *
  8.  * @author JanaMorgan
  9.  * @version 1.0, 11/21/2017
  10.  *
  11.  */
  12. public class ColumnSum {
  13.  
  14. /**
  15.   *
  16.   * Start ColumnSum Here
  17.   *
  18.   */
  19. public static void main(String[] args) {
  20. String usage = "usage: java ColumnSum n \n\twhere n is the column to add";
  21.  
  22. //Make sure the user provides one integer
  23. //via the command line
  24. if (args.length != 1) {
  25. System.out.println(usage);
  26. System.exit(1);
  27. }
  28.  
  29. int column = 0;
  30.  
  31. // hard-coded input
  32. Scanner input = new Scanner(System.in);
  33. double[][] workHours = {{2, 4, 3, 4, 5, 8, 8},
  34. {7, 3, 4, 3, 3, 4, 4},
  35. {3, 3, 4, 3, 3, 2, 2},
  36. {9, 3, 4, 7, 3, 4, 1},
  37. {3, 5, 4, 3, 6, 3, 8},
  38. {3, 4, 4, 6, 3, 4, 4},
  39. {3, 7, 4, 8, 3, 8, 4},
  40. {6, 3, 5, 9, 2, 7, 9}};
  41.  
  42. for (int i = 0; i < workHours.length; i++) {
  43. for (int j = 0; j < workHours[i].length; j++) {
  44. workHours[i][j] = input.nextDouble();
  45. }
  46. }
  47.  
  48. for (int i = 0; i < workHours.length; i++) {
  49. System.out.printf("Sum of the elements at column" + i + "is "
  50. + sumColumn(workHours, i));
  51.  
  52. }
  53.  
  54.  
  55. public static double sumColumn(double[][] workHours, int columnIndex) {
  56. double sum = 0.0;
  57. for (int i = 0; i < workHours.length; i++) {
  58. sum = sum + workHours[i][j];
  59. System.out.println(workHours[i][j]);
  60. sum = sum + workHours[i][j];
  61. }
  62.  
  63. }
  64.  
  65. return sum ;
  66. }
  67.  
  68. public static displayWorkHours(double [][] workHours){
  69. for (int row = i; i < workHours.length; i++) {
  70.  
  71. for (int j = 0; j < workHours[i].length; j++) {
  72. System.out.println("%5.of", workHours[i][j]);
  73. }
  74.  
  75. System.out.printf("\n");
  76. }
  77. }
  78. }
  79.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:55: error: illegal start of expression
    public static double sumColumn(double[][] workHours, int columnIndex) {
    ^
Main.java:55: error: illegal start of expression
    public static double sumColumn(double[][] workHours, int columnIndex) {
           ^
Main.java:55: error: ';' expected
    public static double sumColumn(double[][] workHours, int columnIndex) {
                 ^
Main.java:55: error: '.class' expected
    public static double sumColumn(double[][] workHours, int columnIndex) {
                                              ^
Main.java:55: error: ';' expected
    public static double sumColumn(double[][] workHours, int columnIndex) {
                                                       ^
Main.java:55: error: ';' expected
    public static double sumColumn(double[][] workHours, int columnIndex) {
                                                                        ^
Main.java:68: error: invalid method declaration; return type required
public static displayWorkHours(double [][] workHours){
              ^
7 errors
stdout
Standard output is empty