ajteka
Technical User
- Feb 17, 2009
- 1
How do I get the min/max in this Java program?
import java.util.Scanner;
public class Array2x3
{
public static void main( String args[] )
{
Scanner input = new Scanner( System.in);
int t[][] = new int [2][3];
t[0][0] = 1;
t[0][1] = 1;
t[0][2] = 1;
t[1][0] = 1;
t[1][1] = 1;
t[1][2] = 1;
System.out.println( "Input the 6 numbers for the 2x3 array");
for (int j = 0; j < t.length; j++) // initialize j no semicolon
for (int k = 0; k < t[j].length; k++) // initialize k no semicolon
t[j][k] = input.nextInt();
System.out.println("\t0\t1\t2\n");
//print the headers
for
(int e = 0; e < t.length; e++)
{System.out.print(e);
//print the rows
for
(int r = 0; r < t[e].length; r++)
System.out.printf("\t%d", t[e][r]);
System.out.println();
}// end for
//determine the sum method
int total = ( t[0][0] + t[0][1] + t[0][2]);
System.out.printf("Total first line sum is: %d\n", total );
}//end main
}//end class array
import java.util.Scanner;
public class Array2x3
{
public static void main( String args[] )
{
Scanner input = new Scanner( System.in);
int t[][] = new int [2][3];
t[0][0] = 1;
t[0][1] = 1;
t[0][2] = 1;
t[1][0] = 1;
t[1][1] = 1;
t[1][2] = 1;
System.out.println( "Input the 6 numbers for the 2x3 array");
for (int j = 0; j < t.length; j++) // initialize j no semicolon
for (int k = 0; k < t[j].length; k++) // initialize k no semicolon
t[j][k] = input.nextInt();
System.out.println("\t0\t1\t2\n");
//print the headers
for
(int e = 0; e < t.length; e++)
{System.out.print(e);
//print the rows
for
(int r = 0; r < t[e].length; r++)
System.out.printf("\t%d", t[e][r]);
System.out.println();
}// end for
//determine the sum method
int total = ( t[0][0] + t[0][1] + t[0][2]);
System.out.printf("Total first line sum is: %d\n", total );
}//end main
}//end class array