Sunday, August 18, 2019

BlueJ Program on Fine For Late Return of Book

This is a BlueJ Program on Library late fine calculation.


Write a program to enter number of days late to return a book and display fine amount as per chart.

Number of days
Fine per day (Rs)
First 5
1.50
Nest 7
2.50
Nest 15
5.00
Above 27
10,00





import java.util.*;
public class LateFine
{
    Scanner sc=new Scanner(System.in);
    int d;
    double fine;
   
    public void takeDatas()
    {           
            System.out.print("\nEnter Number of Days Late in Returning Book:");
            d=sc.nextInt();
            if(d<=5)
            {
                 fine=d*1.50;
                 d=0;
                }
                else
                {
                     fine=5*1.50;
                     d=d-5;
                    }
                 if(d<=7 && d >0)
            {
                 fine=fine+d*2.50;
                 d=0;
                }
                else if(d >0)
                {
                     fine=7*2.50;
                     d=d-7;
                    }
                    if(d<=15 && d >0)
            {
                 fine=fine+d*5.00;
                 d=0;
                }
                else if(d >0)
                {
                     fine=15*5.00;
                     d=d-15;
                    }
                    if(d >0)
                    {
                        fine=d*15.00;
                    }
          
        System.out.println("\nTotal Fine:"+fine);
       
    }
           
                  
            public static void main(String args[])
            {
                 LateFine obj=new LateFine();
                 obj.takeDatas();
             }
            }

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner