Answer to Question #248787 in Java | JSP | JSF for Ikraam Kader

Question #248787
Using a Two-Dimensional array, produce the vehicle type sales report and the total sales made for
each vehicle type. If the total sales made per month are greater than or equal to 100, gold status
is awarded. If the monthly sales are less than 100, silver status is awarded.
1
Expert's answer
2021-10-08T23:50:44-0400
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)");
			}




		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS