Conditional Discount
Programming Basics · Java
TASK
Problem
Given purchase total. If it is at least 100, apply a 11% discount. Print the final total.
EXAMPLE
Example
150
133.5
LIMITS
Constraints
0 ≤ total ≤ 10^7; use decimal arithmetic as shown by the solution
LEARN
Theory for this problem
+
The core idea of **Conditional Discount** is to model the requested operation directly: Given purchase total. If it is at least 100, apply a 11% discount. Print the final total. The reference solution uses `Scanner` for input. Keep only the state needed for this result, choose numeric types that cover the stated bounds, and preserve the exact input/output contract. This makes the solution easier to verify on boundary cases and avoids unrelated work.
NEED HELP?
Hints
+
['Follow the statement for **Conditional Discount** literally and identify the smallest state needed to produce its output.', 'The reference solution relies on `Scanner` for input; test the smallest allowed input and one boundary case from the constraints.']
ANSWER
Solution
+
// CodeMaster — Conditional Discount
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
double total = sc.nextDouble();
if (total >= 100) {
total = total * 89.0 / 100.0;
}
System.out.println(total);
}
}