Discount in Java | infoStud blogs

Discount in Java | infoStud blogs, Java Code, Java program, Java Code for Practice


About 

Write a program in Java to find out the discounted amount according to the below mention conditions, also find the total profit. 

Conditions

if Amount <1000: 

Print=  No Discount applicable + Amount


if Amount >=1000 && Amount<=2000; Discount = 20%

Print= Total Pay and Profit


if Amount >=2000 && Amount<=5000; Discount = 25%

Print= Total Pay and Profit


if Amount >=5000; Discount = 30%

Print= Total Pay and Profit

Test Conditions

Amount = 200

Total Pay = 200

Profit = 0


Amount = 7000

Total Pay = 4900 Rs

Profit = 2100 Rs


Amount = 4500

Total Pay = 3375 Rs

Profit = 1125 Rs

Code

import java.util.Scanner;

public class Discount {
    public static void main(String args[]){
        System.out.println("Enter the total Amount");
        Scanner sc = new Scanner(System.in) ;
        int Amount = sc.nextInt();

        if(Amount>1000 && Amount<=2000){
            int Discount = (Amount*20)/100;
            int Total = (Amount-Discount);
            int Profit = (Amount-Total);
            System.out.println("Total Pay: "+Total+" Rs");
      System.out.println("Total Profit: "Profit+" Rs");
        }
        
        if(Amount>=2000 && Amount <=5000){
            int Discount = (Amount*25)/100;
            int Total = (Amount-Discount);
            int Profit = (Amount-Total);
            System.out.println("Total Pay: "+Total+" Rs");
            System.out.println("Total Profit: "Profit+" Rs");
        }
        if(Amount>5000){
            int Discount = (Amount*30)/100;
            int Total = (Amount-Discount);
            int Profit = (Amount-Total);
            System.out.println("Total Pay: "+Total+" Rs");
            System.out.println("Total Profit: "Profit+" Rs");
        }
      if(Amount<=1000){
          System.out.println("No Discount, You have to pay 
full Amount: "+Amount+" Rs");
      }
}
}

Output

Enter the total Amount
200
No Discount, You have to pay full Amount: 200 Rs

Enter the total Amount
7000
Total Pay: 4900 Rs
Total Profit: 2100Rs

Enter the total Amount
4500
Total Pay: 3375 Rs
Total Profit: 1125 Rs









Post a Comment

0 Comments