Example 2-dimensional array

Case: I have the 1000 statistical data will be made birth month, birth day and I was born in the most hours and days what? To get the month and day of birth at random, Random class is used (for the case of real month and day of birth obtained from the database).
sourceprint view?

01.import java.util.Random;
02.class dimensi2
03. (Public static void main (String [] args)
04th Random (x = new Random ();
05.int data [] [] = new int [7] [12];
06.String [] (hr = "Mon", "Tue", "Wed", "Thu", "Fri", "sab", "Sun");
07.String [] bl = {""," Jan "," Feb "," Mar "," Apr "," May "," Jun "," Jul "," Aug ",
08th "Sep", "Okt", "Nov", "Dec");
09.int days, bln;
10.for (int i = 0; i <1000; day =" (x.nextInt" bln =" x.nextInt" column =" 0;" row =" 0;" column =" 0;" max =" data" imax =" 0," jmax =" 0;" row =" 0;" column =" 0;"> max)
29th (max = data [row] [column];
30.imax = line; jmax = column;
31.)
32.)
33.)
34.System.out.println ( "Most born in" + (bl [jmax +1]) +
35th "day" + hr [IMAX] + "" + max + "people");
36.)
37.)

Then how do we know if the correct data on the amount of 1000 people? Can we ensure that the correct calculation? Is the amount of line and perkolomnya is correct?

To answer it all, what if we slightly change the source code above the line and add the calculation perkolom. Here is an example source code.
sourceprint view?
01.import java.util.Random;
02.class dimensi2
03. (Public static void main (String [] args)
04th Random (x = new Random ();
05.int data [] [] = new int [8] [13];
06.String [] (hr = "Mon", "Tue", "Wed", "Thu", "Fri", "sab", "Min", "Jml");
07.String [] bl = {""," Jan "," Feb "," Mar "," Apr "," May "," Jun "," Jul "," Aug ",
08th "Sep", "Okt", "Nov", "Dec", "Jml");
09.int days, bln;
10.for (int i = 0; i <1000; day =" (x.nextInt" bln =" x.nextInt" column =" 0;" row =" 0;" column =" 0;" max =" data" imax =" 0," jmax =" 0;" row =" 0;" column =" 0;"> max)
32. (Max = data [row] [column];
33.imax = line; jmax = column;
34.)
35.)
36.)
37.System.out.println ( "Most born in" + (bl [jmax +1]) +
38th "day" + hr [IMAX] + "" + max + "people");
39.)
40.)

Please examine your own calculations from the data above.

0 komentar:

Post a Comment

+