Question 12
Write a program in Java to input the amount of purchase and calculate the disco
per the following criteria:
Purchase Amount (5)
Discount
from 1 up to 1000
above 1000 up to 5000
above 5000
Print the Purchase Amount, Discount calculated and the Amount to be paid.
nil
10%
20%
Discount = Pur
Purchase Amount > Discount %
100
Amount to be paid = Purchase Amount - Discount.
Question 13
Answers
Answered by
2
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!
Similar questions