Back to Tutorials
Solved ProgramsICSEClass 9Computer Applications

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.

Trushna Tejwani26 January 2020
Solved Programs

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>