1.

Question 12Write a program in Java to input the amount of purchase and calculate the discoper the following criteria:Purchase Amount (5)Discountfrom 1 up to 1000above 1000 up to 5000above 5000Print the Purchase Amount, Discount calculated and the Amount to be paid.nil10%20%Discount = PurPurchase Amount > Discount %100Amount to be paid = Purchase Amount - Discount.Question 13​

Answer»

Answer:

import java.UTIL.*; //Importing util to create Scanner object

class Purchase{

   public static void main() {

       Scanner sc = NEW Scanner(System.in);

       System.out.println("Please enter purchase AMOUNT!");

       double purchaseamt = sc.nextDouble();

       double disc = 0;

       if(purchaseamt > 1000 && purchaseamt <= 5000) {

           disc = 0.1;

       }

       else if(purchaseamt > 5000){

           disc = 0.2;

       }

       System.out.println("Purchase amount: " + purchaseamt);

       System.out.println("DISCOUNT: " + (purchaseamt*disc));

       System.out.println("Amount to be paid: " + (purchaseamt * (1 - disc)));

   }

}

//Hope it helps!



Discussion

No Comment Found