shopkeeper offers 30% discount on purchase
shopkeeper offers two successive discounts
same articles. Write a program in Java to calculate the amount to be paid and the discount
Take the price of an article as the input.
Answers
Answered by
4
Answer:
import java.util.*;
class Sample
{
public static void main(String args[])
{
double s1, shop1,s2, shop2, price;
Scanner demo = new Scanner(System.in);
System.out.println("Enter the amount");
price = demo.nextDouble();
shop1 = price * 30/100;
s1 = price - shop1;
shop2 = price * 20/100;
s2 = (price - shop2) * (1 - 10/100);
if(s1 > s2)
{
System.out.println("1st shopkeeper offer is better");
}
else
{
System.out.println("2nd shopkeeper price is better");
}
}
}
Output:
Enter the amount - 10000
2nd shopkeeper price is better.
Hope this helps!
Similar questions