We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.


+ Link For Assignments, GDBs & Online Quizzes Solution


+ Link For Past Papers, Solved MCQs, Short Notes & More

Assignment No. 01 Fall 2015 CS506- Web Design and Development Total Marks: 20 Due Date: 24/11/2015

Assignment No. 01

 Fall 2015
CS506- Web Design and Development

Total Marks: 20

Due Date: 24/11/2015

Please read the following instructions carefully before solving & submitting assignment:

It should be clear that your assignment will not get any credit  if:

  • The assignment is submitted after due date.
  • The submitted assignment does not open or file corrupt.
  • The assignment is fully or partially copied from (other student or ditto copy from handouts or internet).
  • Student ID is not mentioned in the assignment File or name of file is other than student ID.
  • The assignment is not submitted in .java format.


Uploading instructions

Your submission must include:


  1. All the source code (.java files) and other necessary files to compile and run your program.
  2. You have to make one java file and Upload it on VULMS.


Note: Use Notepad or Notepad++ for coding and JDK package for java source code compilation and running (A guideline document on JDK installation and configuration is given in course download section)


The objective of this assignment is to

  • Give you some practice exercise of Classes and Objects. And how to compile and run java programs.
  • Develop GUI (Graphical User Interface) in java
  • Understand the concept of Collections in java



Problem Statement:                                                        

You are required to write a java program which contains only two classes named as “BookInfo” and “BookMgtSys”.


BookInfo class must have the following data members:

  • ISBN
  • Book Name
  • Author Name
  • Total Books

When you will add book then it will increment variable Total Books and decrement when you will delete book.


BookInfo class must have the following member methods:

  • Default constructor
  • Parameterized constructor
  • addbook () 
  • searchBook ()
  • deleteBook ()


BookMgtSys is a public driver class that contains the main() method. The name of you file should be BookMgtSys as it is a public class in your program.                                                                             

Detailed Description:

Default constructor: The default constructor will create an ArrayList.

Parameterized constructor: It should take three String parameters named as (ISBN, Book Name, and Author Name) and initializes the data members values with the passed parameters.

addBook(): This method will ask the user to enter ISBN, Book name and Author name and then add the book in 

ArrayList and increment the Total Book variable. After successful adding the book, A message box should be displayed containing Book information.

searchBook(): This method takes one parameter which is book name and search the book name in the ArrayList. If search is found then display the Book information otherwise display message that Book not found.

deleteBook(): This method takes one parameter which is book name and delete the book from the ArrayList and then decrement the Total Book variable. 


Use JOptionPane for input and output data.


Sample Output:

Within main() method, the following message box should be displayed.


If user presses 1 then it should ask the user to add further information


Your assignment must be uploaded/submitted at or before 24th Nov, 2015.



For any query about the assignment, contact at cs506@vu.edu.pk


+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Views: 17016


Replies to This Discussion

  • Student ID is not mentioned in the assignment File or name of file is other than student ID.
  • The assignment is not submitted in .java format.

is ka mtlb ha k agr assignment main student id k alava name likha hva ya file java main na hoe to koe number nhe milna.yeni java file or file name as ur id must 

.java my assignment upload ni krna. matlb .txt my assignment upload kary. aur Student ID na likhy?

book info ke class static or inner class hogi tbhi bookmgtsys ke

ye kis ne kha ha

pouch rahi hun?

its complete

create a text document file save code in it replace vuid with ur id like mc1... save file as cs506.java 

package bookpkg;

import java.util.ArrayList;
import javax.swing.JOptionPane;

public class vuid

public static void main(String[] args) 
BookInfo bookObj = new BookInfo();
String inputStr = null;
int intVal = 0;

inputStr = JOptionPane.showInputDialog("Enter 1 to Add Book\n"
+ "Enter 2 to Search Book\nEnter 3 to Delete Book\nEnter 4 to Exit System");
intVal = Integer.parseInt(inputStr);

if(intVal == 1)
String ISBN = JOptionPane.showInputDialog("Enter the ISBN");
String bookName = JOptionPane.showInputDialog("Enter the Book Name");
String authorName = JOptionPane.showInputDialog("Enter the Author Name");

bookObj.addBook(ISBN, bookName, authorName);
else if(intVal == 2)
if(bookObj.totalBooks > 0)
inputStr = JOptionPane.showInputDialog("Enter Book Name to Search");
JOptionPane.showMessageDialog(null, "There is no book in the list!");
else if(intVal == 3)
if(bookObj.totalBooks > 0)
inputStr = JOptionPane.showInputDialog("Enter Book Name to Delete");
JOptionPane.showMessageDialog(null, "There is no book in the list!");
else if(intVal == 4)
JOptionPane.showMessageDialog(null, "Invalid Input!");

public static class BookInfo 
private String ISBN;
private String bookName;
private String authorName;
public int totalBooks = 0;
private ArrayList arr = new ArrayList<BookInfo>();

public BookInfo()
this.ISBN = null;
this.bookName = null;
this.authorName = null;

public BookInfo(String ISBN, String bookName, String authorName)
this.ISBN = ISBN;
this.bookName = bookName;
this.authorName = authorName;

public void addBook(String ISBN, String bookName, String authorName)
BookInfo temp = new BookInfo(ISBN, bookName, authorName);
JOptionPane.showMessageDialog(null, "Book Name: " + bookName + 
" Added Successfully!\nTotal Books: " + this.totalBooks);

public int searchBook(String bookName)
int index = -1;
BookInfo temp = new BookInfo();

for(int i = 0; i < this.arr.size(); i++)
temp = (BookInfo) this.arr.get(i);

index = i;

if(index != -1)
JOptionPane.showMessageDialog(null, "Book Found Successfully!\nISBN: " + temp.ISBN + 
"\nBook Name: " + temp.bookName + "\nBook Author: " + temp.authorName);
return index;
JOptionPane.showMessageDialog(null, "Book Name: " + bookName + 
" Not Found!");
return -1;

public void deleteBook(String bookName)
int index = this.searchBook(bookName);

if(index != -1)
JOptionPane.showMessageDialog(null, "Book Name: " + bookName + 
" Deleted Successfully!\nTotal Remaining Books: " + this.totalBooks);

this code i not workig M.Tariq Sb.

this error shows

ik yhi code to sab sy best working kr rha hai.

there is no error.

plz koi to hlp kr dy mera  JDK instal ni ho rha

 id kahn likhna hy test file m?kahn replac krna hy

dear,i've already gave u a link to understand jdk installment procedure in previous comments.check that.

at the uper part of code, in 1st class 

public class vuid

replace vuid with your bc120....

public class vuid bs090

kea esy ?malika


Looking For Something? Search Here

Latest Activity

Today Top Members 


This is a member-supported website. Your contribution is greatly appreciated!

© 2020   Created by +M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service