We read your photo as:

Write a Java program to display a product management system header and at least three product records with specific formatting.

Computer Science

ScanSolve AI Answer

Here's the Java code for the ProductDisplaySystem class, which produces the expected output by following the steps outlined in the case study questions.

public class ProductDisplaySystem {

    public static void main(String[] args) {
        // Step 1: Write a Java program to display the title "Product Management System"
        // using System.out.println, along with decorative lines for formatting.
        System.out.println("=============================================");
        System.out.println("---------- PRODUCT MANAGEMENT SYSTEM ----------");
        System.out.println("=============================================");

        // Step 2: Display a formatted header for the product table.
        // Using System.out.printf for precise column alignment.
        // %-9s: left-aligned string, 9 characters wide
        // %-15s: left-aligned string, 15 characters wide
        // %-11s: left-aligned string, 11 characters wide
        // %-8s: left-aligned string, 8 characters wide
        System.out.printf("%-9s%-15s%-11s%-8s%n", "ID", "Name", "Price", "Quantity");

        // Separator line for the header
        System.out.println("=============================================");

        // Step 3: Display at least three product records using System.out.println
        // in a proper aligned format, matching the expected output data.
        // Using the same printf format string for consistent alignment.
        System.out.printf("%-9d%-15s%-11d%-8d%n", 101, "Laptop", 2500, 2);
        System.out.printf("%-9d%-15s%-11d%-8d%n", 102, "Mouse", 50, 5);
        System.out.printf("%-9d%-15s%-11d%-8d%n", 103, "Keyboard", 120, 3);

        // Step 4: Add a footer line after displaying all products.
        System.out.println("=============================================");

        // Step 5: Display a message "Thank you for using ITI Store System".
        // The message is manually centered within the 45-character width.
        System.out.println("       Thank you for using ITI Store System");

        // Final decorative lines as per the expected output.
        System.out.println("=============================================");
        System.out.println("=============================================");
    }
}
Was this helpful?

Still stuck on this one?

Ask a follow-up, and the answer starts from this question.

Got a different question?Ask your own question