Share on Google+Share on Google+

MANISHA KUMARI
using array
1 Answer(s)      4 years and 10 months ago
Posted in : Java Beginners

column wise total of a matrix?

Ads

View Answers

May 25, 2012 at 4:25 PM


Java sum of individual columns of matrix

The given code determines the sum of individual column of matrix and display them.

import java.util.*;
class FindSumMatrix{

    public static void main(String[] args){
    Scanner input = new Scanner(System.in);
    int[][] A = new int[3][3];
System.out.println("Enter elements for matrix A : ");
for (int i=0 ; i < A.length ; i++){
for  (int j=0 ; j < A[i].length ; j++){
A[i][j] = input.nextInt();
}
}
int c1=0,c2=0,c3=0;
System.out.println("Matrix A: ");
        for (int i=0 ; i < A.length ; i++){     
            System.out.println();
        for(int j=0 ; j < A[i].length ; j++){
            System.out.print(A[i][j]+" ");
         }
        }
        for (int i=0 ; i < A.length ; i++){     
            c1+=A[i][0];
            c2+=A[i][1];
            c3+=A[i][2];
        }
System.out.println();
System.out.println();
System.out.println("Col1: "+c1);
System.out.println("Col2: "+c2);
System.out.println("Col3: "+c3);

    }
}









Related Tutorials/Questions & Answers:
using array
using array  Circular left shift array element by one position
using array
using array  Circular left shift array element by one position
Advertisements
using array
using array  display 10 digit number using array and print pyramid. 1 1 1 1 1 1 1 1 1 1 1 1
using array
using array  transpose a matrix
using array
using array  transpose a matrix
using array
using array  column wise total of a matrix
using array
using array  read 10 digit number and display (star
using 2D Array
using 2D Array  Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C... the class average. Define the exam answer key as Final Array in your program
using 2D Array
using 2D Array  Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C... the class average. Define the exam answer key as Final Array in your program
Java Programming using array
Java Programming using array  I'm creating a programming using array... Program: import java.io.*; public class Array { public static void main(String args...','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z'}; char ch
Finding duplicates using array in for loop
Finding duplicates using array in for loop  how to find the duplicates in array using for loop
one dimensional array using java
one dimensional array using java  design and implement a java program that will read a file containing numbers and compute the following statistics: the range(low,high) the average and the median
Using [] operator of EL with an Array
Using [ ] operator of EL with an Array   .... An array is a type of container which can hold a fixed number of values of a single type. Array is a collection of similar data types. It means if you have declared
example to booking ticket cinema using array
example to booking ticket cinema using array   example to booking ticket cinema using array
create a string from an array using JavaScript
create a string from an array using JavaScript  How to use "join()" to create a string from an array using JavaScript
use strings as array indexes using JavaScript
use strings as array indexes using JavaScript  How to use strings as array indexes using JavaScript
How to using Binary Search Array Java ?
How to using Binary Search Array Java ?  Hi, I am beginners in Java Programming Language. I am trying to create small application using Array functions. The problem is that how to use binary search array in Java. Please give
Queue implementation using array.
Description: In this tutorial you will see how to implement queue using array and queue insert & delete operations. Code: #include <stdio.h> #define MAX 5 #include <stdlib.h> void insert(int queue[], int *rear
how to create a zip by using byte array
how to create a zip by using byte array  hi, How to convert byte array to zip by using java program.can u plz provide it...... Thanks, krishna
How to save array of UserType in Oracle using Hibernate.
How to save array of UserType in Oracle using Hibernate.  Hi How to save array of UserType in Oracle using Hibernate. CREATE OR REPLACE TYPE...()); ARRAY array =new ARRAY(arrdesc, arg0.getConnection(), null
How to create binary search tree using an array?
How to create binary search tree using an array?  hello people, pls guide me on the topic above. i have an string array, i want to make a binary search tree based on data inside this array. the array contains names of people
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
Convert a string representation of a hex dump to a byte array using Java?
Convert a string representation of a hex dump to a byte array using Java?  Convert a string representation of a hex dump to a byte array using Java
Display tow dimensional array using one for loop in java
Display tow dimensional array using one for loop in java  Display tow dimensional array using one for loop in java
Multiply a range of array elements using Recursion
Multiply a range of array elements using Recursion In this section you will learn how to use recursion to multiply a range of array elements. For this we have created a method rangeMult() that takes three arguments: an int array
Display tow dimensional array by matrix form using one for loop in java
Display tow dimensional array by matrix form using one for loop in java  Display tow dimensional array by matrix form using one for loop in java
how to Insert Array Values Into Separate Rows using java?
how to Insert Array Values Into Separate Rows using java?  how to Insert Array Values Into Separate Rows using java?  class...) { String array[][]={{"1","Angel","Delhi"},{"2","John","Chennai"},{"3","William
Calculating the checksum of a Byte Array by using Adler32
Calculating the checksum of a Byte Array by using Adler32... of a Byte Array using Adler32. Adler32: It is a error checking technique used... field whose type is byte. To calculate the Checksum of the Byte Array by using
Array
Array  What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop?   Hi Friend...(System.in); int array[]=new int[5]; System.out.println("Enter Array Elements
How to Create a ByteBuffer using Byte Array in java.
How to create a ByteBuffer using Byte Array in java.      ..., we will discuss how to creates a buffer using byte array. The ByteBuffer ... Description static ByteBuffer wrap(byte array
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads