Sunday, 12 March 2023

8. A shop during festival season offers a discount 10% for purchase made up to Rs.1,000, 12% for purchase value of Rs.1,000 or more up to Rs 1,500 and 15% for purchase value of Rs.1,500 or more. Write a program to implement the above scheme for a given sales and print out the sales and print out the sales value, discount and net amount payable by a customer. Create necessary methods and constructors

 



import java.util.*;

class Offer
{
    int discount;
    int amount;
    float finalamount;
   
    Offer()
    {
        discount = 0;
        amount = 0;
        finalamount = 0;
    }
   
    void calculate_amount(int amt)
    {
        if(amt <= 1000)
        {
            discount = 10;
        }
        else if(amt < 1500 && amt>1000)
        {
            discount = 12;
        }
        else
        {
            discount = 15;
        }
        finalamount = amt - ((amt*discount) / 100);
        System.out.println("\nyour sales value: " + amt +"\nyour discount:"
+ (amt*discount))/100);

        System.out.println("amount with discount: " + finalamount);
    }
}

class Program8
{
    public static void main(String args[])
    {
       
        Offer obj = new Offer();
        Scanner sc = new Scanner(System.in);
       
        System.out.print("enter your amount: ");
        int amount = sc.nextInt();
       
        obj.calculate_amount(amount);
       
    }
}


No comments:

Post a Comment

python programs

1. sum of two number