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 Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.

📌 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

📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.