Previous Next
0 / 15
Module DEMO-33-69DEMO-OOP-33

Book Price Preview

DEMO-OOP-33 โ€ข Object Oriented Programming

Browser-only practice

Problem Statement

Create two Java files: Main.java and BookPreview.java.

Read the required values, construct a BookPreview object, and print a multiline report.

The report must contain these lines in this order:

  1. Code
  2. Line Total

Use a constructor and keep the object-oriented structure clear.

Input Format

Input is provided as separate whitespace-separated tokens in the same order described in the problem statement.

Output Format

Print the exact multiline report required by the question.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
BK1
4.5
2
Code: BK1
Line Total: 9.00
Input: book code = "BK1", unit price = 4.5, quantity = 2.
Key calculation(s): "Code: " + "BK1" = "Code: BK1" | "Line Total: " + String.format("%.2f", 4.5 * 2) = "Line Total: 9.00".
Output:
Code: BK1
Line Total: 9.00
Sample #2
Public sample
BK9
7.25
3
Code: BK9
Line Total: 21.75
Input: book code = "BK9", unit price = 7.25, quantity = 3.
Key calculation(s): "Code: " + "BK9" = "Code: BK9" | "Line Total: " + String.format("%.2f", 7.25 * 3) = "Line Total: 21.75".
Output:
Code: BK9
Line Total: 21.75

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings