Computer Science, asked by lassie14, 10 months ago

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 the discounts . Take the price of an article as the input.​

Answers

Answered by pavithranatarajan855
25

Answer:

import java.util.*;

class Main {

 public static void main(String[] args) {

  Scanner s=new Scanner(System.in);

  int price=s.nextInt();

  double dis1;

  dis1=price*(0.3);

  //System.out.println(dis1);

  double dis2_first;

  dis2_first=price*(0.2);//calculating 20% discount

  //System.out.println(dis2_first);

  double dis2;

  dis2=(price-dis2_first)*(0.1);//from the getting price //10% discount applied

  //System.out.println(dis2);

  double shop1=price-dis1;

  double shop2=price-dis2;

  System.out.println("The book's final price in shop 1 is "+shop1);

  System.out.println("The book's final price in shop 2 is "+shop2);

 }

}

Explanation:

Answered by keyboardavro
3

Answer:

Explanation:

import java.util.*;

class Main {

public static void main(String[] args) {

 Scanner s=new Scanner(System.in);

 int price=s.nextInt();

 double dis1;

 dis1=price*(0.3);

 //System.out.println(dis1);

 double dis2_first;

 dis2_first=price*(0.2);//calculating 20% discount

 //System.out.println(dis2_first);

 double dis2;

 dis2=(price-dis2_first)*(0.1);//from the getting price //10% discount applied

 //System.out.println(dis2);

 double shop1=price-dis1;

 double shop2=price-dis2;

 System.out.println("The book's final price in shop 1 is "+shop1);

 System.out.println("The book's final price in shop 2 is "+shop2);

}

}

Similar questions