a shopkeeper offers 30% discount on purchasing articles whereas the other shopkeeper offers two successive discounts 20% and 10% for purchasing the same articles. write a program in java to compute and display which is a better offer for the customer. take the price of an article as input. PLEASE GIVE ANSWER IN SCANNER CLASS
Answers
Answered by
139
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!
Answered by
27
Answer:
hope answer will help you
Attachments:
Similar questions