Computer Science, asked by rushilansari, 9 months ago

Program Using-Scanner class
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 to compute and display the discounts .Take the price of an article as the input.

Answers

Answered by granitebala
6

Answer:

mark as brainliest if useful

Explanation:

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