Hi everyone
I thank you a lot for taking the time to read my code
I need to display a two dimensional array, using two classes, calculate the total of each row, and display the maximum total and the minumum total( I was able to do everything except for the maximum and minimum) and I have to submit my project on wednesday, tried my best and thats what I could formulate, please help
This is my code for the first class:
Thats the code for the second class in which I should display the first class:package companyproject; public class company { private int [][] arrayname={{88,45,73},{33,45,58},{58,45,27},{28,45,55}}; private int max=0; private int min=0; public void Output () { for (int x=0; x<3; x++) {System.out.printf("\tProduct %d \t", x+1); } System.out.printf("Total"); for (int row=0; row<arrayname.length; row++) {System.out.println(""); System.out.printf("Salesperson %d\t", row+1); for (int column=0; column<arrayname[row].length; column++) System.out.printf("%d\t\t",arrayname[row][column]); int total = totalx (arrayname[row]); System.out.printf("%d", total); } } public int totalx (int [] arrayname) { int total=0; for (int aaa=0; aaa<arrayname.length; aaa++) {total=total+arrayname[aaa];} if (total > max) {max=total; } System.out.printf("The maximum number is %d", max); if (total < min) {min=total;} System.out.printf("The minimum number is %d", min); return 0; } }
Unfortunately thats what Im getting as an outputpackage companyproject; public class companytext { public static void main (String [] args) { company totally = new company (); totally.Output(); } }
The maximum number is 206The minimum number is 00
after each row (Under total), while I should get the sum of the row
I should get the maximum number and minimum number under the 2d array once
I thank you a lot again for dedicating your time to help me