public class Main {
public static void main(String[] args) {
String[] x = { "Vehicle", "MAY", "JUNE", "JULY", "TOTAL" };
String[] y = { "HATCHBACK", "MINIVAN", "SEDAN", "VAN" };
int[][] MS = { { 30, 15, 40, 0 }, { 30, 55, 40, 0 }, { 13, 20, 48, 0 }, { 17, 27, 25, 0 } };
int[] MT = { 0, 0, 0 };
for (int i = 0; i < x.length; i++) {
if (i == 0) {
System.out.printf("%-17s ", x[i]);
} else {
System.out.printf("%-8s ", x[i]);
}
}
System.out.println();
for (int i = 0; i < MS.length; i++) {
System.out.printf("%-17s ", y[i]);
MS[i][3] = (MS[i][0] + MS[i][1] + MS[i][2]);
MT[0] += MS[i][0];
MT[1] += MS[i][1];
MT[2] += MS[i][2];
for (int j = 0; j < MS[i].length; j++) {
System.out.printf("%-8s ", MS[i][j]);
}
System.out.println();
}
System.out.printf("%-17s ", "MONTHLY TOTAL");
for (int i = 0; i < MT.length; i++) {
System.out.printf("%-8s ", MT[i]);
}
System.out.println("\n\n-----------------------------------------");
System.out.println("TOTAL SALES OF VEHICLES");
System.out.println("--------------------------------------------");
for (int i = 0; i < y.length; i++) {
if (MS[i][3] >= 100) {
System.out.printf("%-10s%-5d%-5s\n", y[i], MS[i][3], "(Gold Star)");
} else {
System.out.printf("%-10s%-5d%-5s\n", y[i], MS[i][3], "(Silver Star)");
}
}
}
}
Comments
Leave a comment