Results 1 to 10 of 11
Threaded View
-
4th Dec 2011, 11:46 AM #2MemberWebsite's:
imdber.org justpaste.me// May i ask why u instantiated outside the main method when u can instantiate it inside?
Code:import java.io.*; public class ArrayTest { public static void main(String[] args)throws IOException{ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); int y=0; int x=0; int row=0; int col=0; System.out.print("Number of rows: "); int a = Integer.parseInt(bf.readLine()); System.out.print("Number of columns: "); int b = Integer.parseInt(bf.readLine()); int array[][] = new int[a][b]; for(x=0; x<array.length;x++){ for(y=0; y<array[x].length;y++){ System.out.print("Enter element ["+x+"]["+y+"]: "); array[x][y]=Integer.parseInt(bf.readLine()); } } for(x=0;x<array.length;x++){ for(y=0;y<array[x].length;y++){ System.out.print(array[x][y]+" "); row+=array[x][y]; } System.out.println("= "+row); row=0; } for(y=0;y<array[a-1].length;y++){ System.out.print("= "); } System.out.println(); for(y=0;y<array[a-1].length;y++){ for(x=0; x<array.length;x++){ col+=array[x][y]; } System.out.print(col+" "); col=0; } } }
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Java stinks: Turn off your Java browser plugin
By Loget in forum General DiscussionReplies: 37Last Post: 5th Sep 2012, 07:40 AM -
please help me in java
By shanshayan in forum Webmaster DiscussionReplies: 2Last Post: 10th Jan 2012, 06:48 AM -
HELP: Java countdown
By CuraHack in forum Web Development AreaReplies: 4Last Post: 9th Nov 2011, 02:42 AM -
In need of JAVA Developer
By avngr in forum Web Development AreaReplies: 2Last Post: 1st Sep 2011, 02:44 PM -
Some help need in Java programing
By bapi21 in forum Web Development AreaReplies: 1Last Post: 10th Jul 2011, 01:08 PM
themaCreator - create posts from...
Version 3.47 released. Open older version (or...