Advertisements
Advertisements
Question
A dealer allows his customers a discount of 25% and still gains 25%. Write a program to input the cost of an article and display its selling price and marked price.
[Hint: SP = `((100 + p%)/100)` * CP and MP = `(100/(100 − d%))` * SP]
Answer in Brief
Solution
import java.util.*;
public class KboatCalculatePrice
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter cost price of article: ");
double cp = in.nextDouble();
int disc = 25, profit = 25;
double sp = 0.0, mp = 0.0;
sp = ((100 + profit) / 100.0) * cp;
System.out.println("Selling price of article = Rs. " + sp);
mp = (100.0 / (100 - disc)) * sp;
System.out.println("Marked price of article = Rs. " + mp);
}
}
shaalaa.com
Is there an error in this question or solution?