Computer Science, asked by pbguardian07, 1 month ago

A shopkeeper offers 30% discount on purchasing an article whereas the other shopkeeper offers two successive discounts 20% and 10% for purchasing the same article. Write a program in Java to compute and display the discounts. Take the price of an article as the input.

Answers

Answered by Akshara6c
8

Answer:

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);

}

}

Answered by sandhrasiju2021
0

Answer:

import java.util.*;

public class Discounts

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

int prize;

double dis1,dis2,dis3,fdis1,fdis2,fdis3,amt;

String name;

System.out.println("Name of the article");

name=in.nextLine();

System.out.println("Prize of the article");

prize=in.nextInt();

dis1=prize*30/100;

fdis1=prize-dis1;

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

System.out.println("prize after 30% of discount:"+fdis1);

dis2=prize*20/100;

fdis2=prize-dis2;

dis3=fdis2*10/100;

fdis3=fdis2-dis3;

amt=fdis3;        

System.out.println("20% discount: "+dis2);

System.out.println("10% discount: "+dis3);

System.out.println("Total prize after the succesive discounts: "+amt);

}

}

Explanation:

Description of Variables

dis1 - discount 1 (double)                 fdis1 - final discount 1 (double)

dis2 - discount 2 (double)                fdis2 - final discount 2 (double)

dis3 - discount 3   (double)              fdis3 - final discount 3 (double)

amt - amount (double)                    

Similar questions