Tuesday, November 3, 2015

BlueJ Project on Library Management


This project is on library management. Books are issued to students from library. Details of the students like Name of the student, class in which he/she reads, Regd. No, section, issue and return date of the book are kept in record along with the book name, author of the book and price of the book.

For delay of returning the book, a fine is imposed on students according to the following:

First 7 days: Fine 0
 Next 8 days: Fine Rs. 2 per day
 Next 15 days: Fine Rs. 3.50 per day
 Above 30 days: Rs. 5.50 per day + price of the book


The program deals with the above library management.

Program


import java.io.*;
class Library
{
 String name, regd_no,cl,sec,book,author,issue,ret;
 double fine,price;
 int datediff;
 String s1,s2;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 public void take() throws IOException
 {
  System.out.println("Enter Student Name:");
  name=br.readLine();
  System.out.println("Enter Student Regd. No:");
  regd_no=br.readLine();
  System.out.println("Enter Class:");
  cl=br.readLine();
  System.out.println("Enter Section:");
  sec=br.readLine();
  System.out.println("Enter Name of the Book issue:");
  book=br.readLine();
  System.out.println("Enter Author Name of the Book:");
  author=br.readLine();
  System.out.println("Enter Date of Issue of the Book (dd/mm/yyyy):");
  issue=br.readLine();
  System.out.println("Enter Date of Return of the Book (dd/mm/yyyy):");
  ret=br.readLine();
  s1=issue;
  s2=ret;
  diff();
  }
  private void diff()
  {
   int d,d1,m,m1,y,y1;
   d1=0;
   d=0;
   m1=0;m=0;
   int i,x=0;
   datediff=0;
   while(true)
   {
    i=issue.indexOf("/");
    if (i<0)<0 o:p="">
    break;
    if(x==0)
    {
     d=Integer.parseInt(issue.substring(0,i));
     issue=issue.substring(i+1);
     }
    else if(x==1)
    {
     m=Integer.parseInt(issue.substring(0,i));
     issue=issue.substring(i+1);
     }
    x++;
    }
    y=Integer.parseInt(issue);
    x=0;
   while(true)
   {
    i=ret.indexOf("/");
    if (i< 0)<0 o:p="">
    break;
    if(x==0)
    {
     d1=Integer.parseInt(ret.substring(0,i));
     ret=ret.substring(i+1);
     }
    else if(x==1)
    {
     m1=Integer.parseInt(ret.substring(0,i));
     ret=ret.substring(i+1);
     }
    x++;
    }
    y1=Integer.parseInt(ret);
   m1=m1+(12*(y1-y));
   if(m1-m>2)
   datediff=31;
   // date diff is more than 30
   else if(m1-m>1)
   datediff=d1+30-d;
   else
   datediff=d1-d;
   fine();
   }
   private void fine()
   {
    if(datediff<=7)
    fine=0;
    else if(datediff<=15)
    fine=2*datediff;
    else if(datediff<=30)
    fine=3.5*datediff;
    else
    fine=fine+5.5*datediff;
    show();
    }
 private void show()
 {
  System.out.println("Name of the student:"+name);
  System.out.println("Regd No of the student:"+regd_no);
  System.out.println("Class of the student:"+cl);
  System.out.println("Section of the student:"+sec);
  System.out.println("Book issue to the student:"+book);
  System.out.println("Author of the Book:"+author);
  System.out.println("Book issue on:"+s1);
  System.out.println("Return Date of the Book:"+s2);
  System.out.println("Fine Amount:"+fine);
  }
    }
   


Variable Description




Variable Name
Type
Purpose
name
String
Holds name of the student
regd_no
String
Holds Regd No of the student
cl
String
Holds class of the student
sec
String
Holds section of the student
book
String
Holds name of the book
author
String
Holds author’s name of the book
issue
String
Holds issue date of the book in dd/mm/yyyy format
ret
String
Holds return date of the book in dd/mm/yyyy format
fine
double
Holds fine amount
price
double
Holds price of the book
datediff
int
Difference of days between issue and return date of book
s1
String
Holds issue date of the book in dd/mm/yyyy format
s2
String
Holds return date of the book in dd/mm/yyyy format
d
int
Holds the issue date only
d1
int
Holds the return date only
m
int
Holds the issue month no only
m1
int
Holds the return month only
y
int
Holds the issue year
y1
int
Holds the return year

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner