Calculate the Net bill program
Write a program to accept the total cost from the user. Calculate the discount and Net bill according the given rates. Print the details of the user.
Write a program to accept the total cost from the user. Calculate the discount and Net bill according the given rates. Print the details of the user.
import java.io.*;
public class bill
{
public static void main() throws IOException
{
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the total cost");
double T=Double.parseDouble(br.readLine());
double D=0.0;
double NA=0.0;
if(T<=2000)
{
D=T*5/100;
NA=T-D;
}
else if(T>=2001&&T<=5000)
{
D=T*25/100;
NA=T-D;
}
else
{
D=T*50/100;
NA=T-D;
}
System.out.println("Total cost is"+T+"Rs.");
System.out.println("The discount is"+D+"Rs.");
System.out.println("Net bill is="+NA+"Rs.");
}
}<tbody>
Enter the total cost 4000
Total cost is4000.0Rs.
The discount is1000.0Rs.
Net bill is=3000.0Rs.
</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.