Home / Programs / During a special sale at a store, a 10% discount is taken on purchases over ₹ 1000/-. Write a program that asks for the amount of purchases, then calculates the discounted price.
Programming Example

During a special sale at a store, a 10% discount is taken on purchases over ₹ 1000/-. Write a program that asks for the amount of purchases, then calculates the discounted price.

👁 10 Views
💻 Practical Program
📘 Step by Step Learning
Study this program carefully to understand the logic, output, and explanation in a structured way.

Information & Algorithm

Given Input:


Expected Output:


Program Code

import java.util.Scanner;

public class SpecialSale {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter purchase amount (?): ");
        double amount = sc.nextDouble();

        double discount = 0;
        double finalAmount;

        // Apply 10% discount if amount is more than 1000
        if (amount > 1000) {
            discount = amount * 0.10;
        }

        finalAmount = amount - discount;

        System.out.println("Original Amount: ?" + amount);
        System.out.println("Discount: ?" + discount);
        System.out.println("Amount to Pay: ?" + finalAmount);

        sc.close();
    }
}

Explanation

Logic Used

  • If purchase amount > ?1000,
    → Discount = 10% of amount

  • Otherwise,
    → No discount

  • Final Amount = Amount − Discount

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.