Computer Science, asked by vinodanck631, 11 months ago

A shopkeeper offers 30% discount on purchasing articles whereas the other shopkeeper offers two successive discounts 20%and 10% gor purchasing the same articles write a program to compute and display the discounts . Take the price of the article as input .(Scanner class )

Answers

Answered by Ragab20
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

Answered by kitkat333
1

import java.util.Scanner;

public class KboatDiscounts

{

   public static void main(String args[]) {

       Scanner in = new Scanner(System.in);

       System.out.print("Enter price of article: ");

       double price = in.nextDouble();

       

       double d1 = price * 30 / 100.0;

       double amt1 = price - d1;

       System.out.println("30% discount = " + d1);

       System.out.println("Amount after 30% discount = " + amt1);

       

       double d2 = price * 20 / 100.0;

       double amt2 = price - d2;

       double d3 = amt2 * 10 / 100.0;

       amt2 -= d3;

       System.out.println("20% discount = " + d2);

       System.out.println("10% discount = " + d3);

       System.out.println("Amount after successive discounts = " + amt2);

   }

}

HOPE THIS HELPS:)

Similar questions