Loss percentage calculation program
Write a program to input cost price and selling price and calculate the loss percentage and print.
Write a program to input cost price and selling price and calculate the loss percentage and print.
import java.io.*;
public class loss
{
public static void main() throws IOException
{
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the cost price");
double CP=Double.parseDouble(br.readLine());
System.out.println("Enter the selling price");
double SP=Double.parseDouble(br.readLine());
String item_name="Article";
double loss=CP-SP;
double loss_per=loss/CP*100;
System.out.println("The loss percent is="+loss_per);
}
}
}<tbody>
Enter the cost price 2000
Enter the selling price 1789
The loss percent is=10.549999999999999
</tbody>
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.