You are on page 1of 4

public class MonthlySales {

public static void monthlyCombSales(int x[][]) {


int quarterPos = 1;
int quarterTotal = 0;
for (int column = 0; column < x.length ; column++){
for (int row = 0; row < x[column].length ; row++){
quarterTotal += x[column][row];
}
System.out.print("For quarter " + (quarterPos+column) +" is " +
quarterTotal);
System.out.println();
}
}

public static int quarterlySales(int y[][]){


int month = 1; int quarterSale=0;
for (int row = 0; row < y[row].length; row++){
for (int column = 0; column < y.length; column++){
quarterSale += y[column][row];
}
System.out.print("For month " + (month+row) +" is " + quarterSale);

System.out.println();
}
return quarterSale;

}
public static void combQuartSales(int highStreet[][], int mallStreet[][]){
int total = 0; int r=0;
for (int counts = 0; counts < 4; counts++){
int j = 0;
for (int i = 0; i < 3; i++){
if (j < 3){
total = total + highStreet[r][j];
j++;
}
}
int m = 0;
for (int k= 0; k < 3; k++){
if (m < 3){
total = total + mallStreet[r][m];
m++;
}

}
r++;
System.out.println("Quarterly sales for both shops: " + total);
total = 0;
}
}

public static int annualSales(int y[][]) {


int total = 0; int saleTotal = 0;
for (int i=0; i<3; i++) {
for (int k=0; k<4; k++) {
total += y[k][i];
}
saleTotal += total;
}

return saleTotal;
}
public static void rankMonthlyPerformance (int high[][], in mall[][]) {

int month = 1;
for (int i=0; i < 3; i++) {
int quarterSale1=0; int quarterSale2=0;
for (int j = 0; j < 4; j++){
quarterSale1 += high[j][i];
}

for (int k = 0; k < 4; k++){


quarterSale2 += mall[k][i];
}

if (quarterSale1 > quarterSale2) {


System.out.println("For month " + month + " High street
shop performed better!");
}
else {
System.out.println("For month " + month + " Mall Branch
shop performed better!");
}

month++;
}
}

public static void rankQuarterlyPerformance(int high[][], int mall[][]) {


int qPos = 1;
for (int i=0; i < 4; i++){
int quarterTotal1=0; int quarterTotal2=0;
for (int j = 0; j < 3; j++){
quarterTotal1 += high[i][j];
}

for (int k = 0; k < 3 ; k++){


quarterTotal2 += mall[i][k];
}

if (quarterTotal1 > quarterTotal2) {


System.out.println("For quarter " + qPos+ "High street shop
performed better!");
}
else {
System.out.println("For quarter " + qPos + " Mall Branch shop
performed better!");
}
qPos++;

}
public static void main (String[] args){
int highStreet[][] = {{42000, 48000, 50000}, {52000, 58000, 60000}, {46000,
49000, 58000}, {50000, 51000, 61000}};
int mallBranch[][] = {{57000, 63000, 60000}, {70000, 67000, 73000}, {67000,
65000, 62000}, {72000, 69000, 75000}};

String x = "\nHigh Street Sales";


System.out.println(x);
monthlyCombSales(highStreet);
System.out.println("\nMall Branch Sales");
monthlyCombSales(mallBranch);
System.out.println("----------------------------");
System.out.println("----------------------------");
System.out.println("\n");
System.out.println("High Street Sales");
quarterlySales(highStreet);
System.out.println("\nMall Branch Sales");
quarterlySales(mallBranch);

System.out.println("----------------------------");
System.out.println("----------------------------");

System.out.println("\n***The combined respective quarterly sales for the


two shops****");
combQuartSales(highStreet, mallBranch);
System.out.println("----------------------------");
System.out.println("----------------------------");

System.out.println("\nAnnual High Street Sales: " +


annualSales(highStreet));

System.out.println("Annual Mall Branch Sales: " + annualSales(mallBranch));

System.out.println("\n");
System.out.println("Grand Annual Sales for the two Shops: " +
(annualSales(highStreet) + annualSales(mallBranch)));

System.out.println("\n");
System.out.print("According to the annually sales for both shops: ");

if (annualSales(highStreet) > annualSales(mallBranch)) {


System.out.print("High Street shop performed better!\n");
}
else {
System.out.println("Mall Branch shop performed better!\n");
}

rankMonthlyPerformance(highStreet, mallBranch);

System.out.println("----------------------------");
System.out.println("----------------------------");

rankQuarterlyPerformance(highStreet, mallBranch);
}
}

You might also like