You are simply required to submit a source file ( .java ) that includes the implementation of the above mentioned program.
Write a java program that has following class
Opt_library
Which should have the following Private data members and member functions.
1- card_number
2- valid_days_left
3- books_issued
4- books_returned
5- Number_of_books
Make a member function that will find out the previous status of the card before making the next operation. This member function will check whether it is required to return some books on the particular card or the status has been cleared.
The status will be cleared if all the issued books have also returned.
Display the messages accordingly, saying
"The status has been cleared"
or
"No further operations can be made. Some books are still not returned"
If the user enters books_returned which are more than books_issued, an appropriate message should be displayed saying;
"Number of books returned cannot be greater than number of books issued"
Make a member function named as issue_books that issue books against the current operation on the library card.
More than 2 books cannot be issued in one operation. If a user enters more than 2 books for the Number_of_books, the program displays the message saying;
"More than 2 books cannot be issued at a time"
Books can only be issued if the valid_days_left are greater than or equal to 15 days.
If the valid_days_left is less than 15, the program quits after displaying an appropriate message saying;
"Books cannot be issued, there are not enough days left for the validity of card"
Make another member function named as display that will finally display the message after the issue of the books saying'
Number_of_books book(s), issued to the card_number.
Checks for negative values will be encouraged to implement.
Write getters and setters of all data member. Also write constructor and destructor.
Your output should be similar to the following:
Sample output 1: (when user enters 2 books to be issued)
Enter card number: 142
Enter days left for the validation: 30
Enter number of books issued previously: 3
Enter number of books returned previously: 3
Card Number: 142
Valid days left: 30
Books issued previously: 3
Books returned previously: 3
The status has been cleared
Please enter the number of books to be issued: 2
2 book(s), issued to the card number 142
Sample output 2: (when user enters more than 2 books to be issued)
Enter card number: 987
Enter days left for the validation of : 20
Enter number of books issued previously: 6
Enter number of books returned previously: 6
Card Number: 987
Valid days left: 20
Books issued previously: 6
Books returned previously: 6
The status has been cleared
Please enter the number of books to be issued: 3
More than 2 books can not be issued at a time
Please enter the number of books to be issued: 1
1 book(s), issued to the card number 987
Sample output 3: (when some books issued previously, have not been returned)
Enter card number: 650
Enter days left for the validation: 30
Enter number of books issued previously: 6
Enter number of books returned previously: 3
No further operations can be made. Some books are still not returned
وهنا محاولاتي ... ولكن فيه إيرور والكلاس تيست لم اصل لحل معه فأرجوا من الأعضاء الكريمين الإسراع في حله وشكرا" مقدما""""
import java.util.Scanner;
public class Opt_library {
private String card_number;
private String vaild_day_left;
private String books_issued;
private String books_returned;
private int Numbers_of_books;
// int person1;
int person2;
public String getcard_number()
{
return card_number;
}
public void setcard_number(String card_number1)
{
card_number=card_number1;
}
//2 vaild_day_left
public String getvaild_day_left()
{
return vaild_day_left;
}
public void setvaild_day_left(String vaild_day_left1)
{
vaild_day_left=vaild_day_left1;
}
//3 books_issued
public String getbooks_issued()
{
return books_issued;
}
public void setbooks_issued(String books_issued1)
{
books_issued=books_issued1;
}
public String getbook_returned()
{
return books_returned;
}
public void setbook_returned(String book_returned1)
{
books_returned=book_returned1;
}
public int getNumbers_of_books()
{
return Numbers_of_books;
}
public void setNumbers_of_books(int Numbers_of_books1)
{
Numbers_of_books=Numbers_of_books1;
}
public void card_number1()
{
Scanner input = new Scanner(System.in);
System.out.println("Enter card number:");
int card_number= input.nextInt();
System.out.println("Enter days left for the validation:");
int vaild_day_left = input.nextInt();
System.out.println("Enter number of books issued previously:");
int books_issued = input.nextInt();
System.out.println("Enter number of book returned previously:");
int books_returned= input.nextInt();
if(books_issued>books_returned)
{
System.out.println("No further operation cnn be made >Some books are stioll not returned");
}
if(books_issued==books_returned)
{
System.out.println("The status has been cleard");
}
if(books_issued<books_returned)
{
System.out.println("No further operation cnn be made >Some books are stioll not returned");
}
}
}