ArrayP4 - import java.util import java.lang import java.io...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; import java.lang.*; import java.io.*; import java.text.*; import java.math.*; import java.text.DecimalFormat; // Jeremy Debruce / public class ArrayP4 { static final int rows = 5; static final int columns = 5; static int i, j, n=1,min,row,md=0,sd=0,max=0; public static void main(String[] args) { //Stores array System.out.println("A"); int[][] array = new int [5][5]; int[][] arrayA= new int [5][5]; int[][] arrayB= new int [5][5]; for (i=0;i<5;i++) { for (j=0;j<5;j++) { array[i][j]=n; arrayA[i][j]=n; arrayB[i][j]=n; n=n+1; } } //Outputs the array for (i=0;i<5;i++) { for (j=0;j<5;j++) System.out.printf("%5s" ,array[i][j]+" "); System.out.println(); } System.out.println(); System.out.println(); System.out.println(); //outputs the sum of the third row System.out.println("B"); int sum=0; for (j=0;j<5;j++) sum=array[2][j]+ sum; System.out.println(); System.out.println("Sum => "+sum); System.out.println(); //interchange 3rd and 4th column System.out.println("F"); int temp;
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
for(i=0;i<5;i++) { temp = array[i][1]; array[i][1]=array[3][i]; array[3][1]=temp; } for(i=0;i<5;i++) { for(j=0;j<5;j++) System.out.printf("%5s" ,array[i][j]+" "); System.out.println(); }
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern