1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Array Table assignments

Discussion in 'Java' started by wan Toushiro, May 30, 2012.

  1. wan Toushiro

    wan Toushiro New Member

    Joined:
    May 30, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    could anyone please help me with this problem? i really need the answer as soon as possible. Thank you.

    here is the question:

    here is the question :

    Write a Java program that

    1.queries a user for the number of rows and columns of a contingency table,
    2.read the data, row by row and
    3.displays the data in tabular form along with the row totals, column totals and grand total.

    For example if the six data of 2x3 table are

    1,3,6,7,9, and 8. the program displays these six numbers together with the appropriate totals as

    1 3 6 | 10
    7 9 8 | 24
    8 12 14 | 34
    The character '|' is used to separate the data from the row totals

    here is my code..

    Code:
    import java.util.Scanner;
        import java.util.*;
    
    public class JavaApplication16 {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
            
            int numRows;
            int numCols;
            int sizeTable;
            Scanner readinput = new Scanner(System.in);
            
            System.out.println(" Enter the size of table: Rows*Columns " );
            
            numRows = readinput.nextInt();
            numCols = readinput.nextInt();
            
            sizeTable = numRows*numCols;
            
            System.out.println(" The size of table are : "+numRows+"*"+numCols+"="+sizeTable );
            //
            int numData;
            System.out.println(" Enter the data for the table: ");
            numData = readinput.nextInt();
            
            int[][]  ContigencyTable;
            ContigencyTable = new int[numRows][numCols];
     
    Last edited by a moderator: May 31, 2012
  2. wan Toushiro

    wan Toushiro New Member

    Joined:
    May 30, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    anybody could help me?
     

Share This Page