Click here to Skip to main content
15,887,347 members
Home / Discussions / Java
   

Java

 
AnswerRe: Java beginner question Pin
Richard MacCutchan5-Oct-15 20:51
mveRichard MacCutchan5-Oct-15 20:51 
Questionwhat is java version of window desktop elements Pin
neodeaths5-Oct-15 0:37
neodeaths5-Oct-15 0:37 
AnswerRe: what is java version of window desktop elements Pin
Richard MacCutchan5-Oct-15 0:45
mveRichard MacCutchan5-Oct-15 0:45 
QuestionHow can I implement Markov's algorithm with variables and markers? Pin
Riccardo Bove4-Oct-15 10:31
Riccardo Bove4-Oct-15 10:31 
Questionjava Pin
Member 120298853-Oct-15 0:39
Member 120298853-Oct-15 0:39 
AnswerRe: java Pin
Richard MacCutchan3-Oct-15 1:22
mveRichard MacCutchan3-Oct-15 1:22 
QuestionJava problem beginner Pin
Member 120276961-Oct-15 23:33
Member 120276961-Oct-15 23:33 
AnswerRe: Java problem beginner Pin
Richard MacCutchan2-Oct-15 0:17
mveRichard MacCutchan2-Oct-15 0:17 
OK, that seems to work quite well, so all you need is to add the calculations of the averages and sums. You can do these as you print the rows and columns, althugh you will need an extra array for the column sums, and a variable for the averages. Something like:
Java
    int[][] matrix = new int[A][B];
    int sums[] = new int[B];
    int average;

    for (int row=0; row<matrix.length; ++row)
    for (int column=0; column<matrix[row].length; ++column) {
        System.out.println("Set element "+row+", "+column);
        matrix[row][column] = scanner.nextInt();
    }

    System.out.println("Your matrix:");
    for (int row=0; row<matrix.length; ++row) {
        average = 0;
        for (int column=0; column<matrix[row].length; ++column) {
        System.out.print(matrix[row][column]+"\t");
        average += matrix[row][column];
        sums[column] += matrix[row][column];
        }
        System.out.println("- average: " + (average / B));
    }
    for (int column=0; column<matrix[0].length; ++column) {
        System.out.print("----\t");
    }
    System.out.println();
    for (int column=0; column<matrix[0].length; ++column) {
        System.out.print(sums[column]+"\t");
    }
    System.out.println();
}

You could also improve the accuracy of the averages by using a float type rather than integer.
GeneralRe: Java problem beginner Pin
Member 120276962-Oct-15 1:46
Member 120276962-Oct-15 1:46 
GeneralRe: Java problem beginner Pin
Richard MacCutchan2-Oct-15 1:53
mveRichard MacCutchan2-Oct-15 1:53 
QuestionStoring private data in the cloud via hash functions? Pin
Keld Ølykke30-Sep-15 10:30
Keld Ølykke30-Sep-15 10:30 
QuestionJava Graphics class Pin
Member 1200394822-Sep-15 8:04
Member 1200394822-Sep-15 8:04 
AnswerRe: Java Graphics class Pin
Richard MacCutchan22-Sep-15 21:11
mveRichard MacCutchan22-Sep-15 21:11 
AnswerRe: Java Graphics class Pin
Anji Reddy26-Sep-15 6:20
Anji Reddy26-Sep-15 6:20 
QuestionUninstalling the Sun java application server problems Pin
Stephen Holdorf22-Sep-15 2:01
Stephen Holdorf22-Sep-15 2:01 
AnswerRe: Uninstalling the Sun java application server problems Pin
Richard MacCutchan22-Sep-15 21:09
mveRichard MacCutchan22-Sep-15 21:09 
QuestionWhile upgrading the axis2, i got the following java.lang.RuntimeException: Undefined 'Security policy namespace cannot be null.' resource property Pin
RohitSonawat17-Sep-15 1:26
RohitSonawat17-Sep-15 1:26 
SuggestionRe: While upgrading the axis2, i got the following java.lang.RuntimeException: Undefined 'Security policy namespace cannot be null.' resource property Pin
Richard MacCutchan17-Sep-15 1:54
mveRichard MacCutchan17-Sep-15 1:54 
Questiontranscript management using java Pin
Member 1197700411-Sep-15 4:45
Member 1197700411-Sep-15 4:45 
AnswerRe: transcript management using java Pin
Richard MacCutchan11-Sep-15 5:31
mveRichard MacCutchan11-Sep-15 5:31 
Questionbooks examples of precedures stored for sqlserver Pin
DAGOBERTO PAVEZ CASELLA8-Sep-15 6:37
professionalDAGOBERTO PAVEZ CASELLA8-Sep-15 6:37 
AnswerRe: books examples of precedures stored for sqlserver Pin
Afzaal Ahmad Zeeshan8-Sep-15 6:53
professionalAfzaal Ahmad Zeeshan8-Sep-15 6:53 
AnswerRe: books examples of precedures stored for sqlserver Pin
Wendelius8-Sep-15 7:08
mentorWendelius8-Sep-15 7:08 
QuestionDOM XSS and createElement() and getElementsByTagName() methods Pin
Supriya Tonape2-Sep-15 19:54
Supriya Tonape2-Sep-15 19:54 
SuggestionRe: DOM XSS and createElement() and getElementsByTagName() methods Pin
Richard MacCutchan2-Sep-15 21:14
mveRichard MacCutchan2-Sep-15 21:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.