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
{
BufferedReader br=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
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.