0% found this document useful (0 votes)
12 views5 pages

Java Et1

The document describes a Java program that implements a library management system using object-oriented programming principles. The program uses classes like text_book, DVD, and NOVEL that extend a base library class. These classes set and get details like name, author, and year. The main method creates objects of these classes, takes input using Scanner, and displays output based on user's choice selected using switch case. The program demonstrates concepts like classes, inheritance, input/output and switch case statements.

Uploaded by

Vansh Namdev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Java Et1

The document describes a Java program that implements a library management system using object-oriented programming principles. The program uses classes like text_book, DVD, and NOVEL that extend a base library class. These classes set and get details like name, author, and year. The main method creates objects of these classes, takes input using Scanner, and displays output based on user's choice selected using switch case. The program demonstrates concepts like classes, inheritance, input/output and switch case statements.

Uploaded by

Vansh Namdev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

WORKSHEET 1

Student Name: Vansh Namdev UID:22BCS10714


Branch: CSE Section/Group:610- ‘B’
Semester:3rd Date of Performance:28/08/23
Subject Name: Subject Code: 22CSH-201

1. Aim: Being a student means that you spend a lot of the time reading
which may include your primary (SE text book/ some of the DVDs
from your online lecture) list create reviews and possibly some
random novels of your own interest. you make the unusual decision
to use software to manage your book half time you have a technical
mindset you own personal book half can be implemented by
employing proper oops ideas to brainstorm and write java code

2. Source Code:

import java.util.Scanner;

class library
{
String Name;
int publishing_year;
}
class text_book extends library
{
String Writer;
Scanner sc=new Scanner(System.in);
public void set()
{
System.out.print("Enter the name of the book :");
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Name=sc.next();
System.out.print("Enter the name of Writer of the book :");
Writer = sc.next();
System.out.print("Enter the publishing_year of the book :");
publishing_year=sc.nextInt();
}

public void get()


{
System.out.println("details of the books are.......\nName =
"+Name+"\nWriter = "+Writer+"\npublishing_year =
"+publishing_year);
}
}
class DVD extends library
{
int Duration;
int size;
Scanner sc=new Scanner(System.in);
public void set()
{
System.out.print("Enter the name of the DVD :");
Name=sc.next();
System.out.print("Enter the Duration of DVD :");
Duration = sc.nextInt();
System.out.print("Enter the SIze of the DVD :");
size=sc.nextInt();
}
public void get()
{
System.out.println("details of the DVD are.......\nName =
"+Name+"\nDuration = "+Duration+"\nSIZE = "+size);
}
}
class NOVEL extends library
{
String Writer;
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Scanner sc=new Scanner(System.in);


public void set()
{
System.out.print("Enter the name of the NOVEL :");
Name=sc.next();
System.out.print("Enter the name of Writer of the NOVEL :");
Writer = sc.next();
System.out.print("Enter the publishing_year of the NOVEL :");
publishing_year=sc.nextInt();
}
public void get()
{
System.out.println("details of the NOVEL are.......\nName =
"+Name+"\nWriter = "+Writer+"\npublishing_year =
"+publishing_year);
}
}
public class EVALUATION_1
{
public static void main(String []args)
{
text_book TB=new text_book();
DVD D=new DVD();
NOVEL N=new NOVEL();
TB.set();
D.set();
N.set();
Scanner sc=new Scanner(System.in);
System.out.print("Enter 1 For Books Details\nEnter 2 for DVD
Details\nEnter 3 for Novel Details\nENter your choice :");
int choice=sc.nextInt();

switch(choice)
{
case 1:
{
TB.get();
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

break;
}
case 2:
{
D.get();
break;
}
case 3:
{
N.get();
break;
}
default:
{
System.out.println("Wrong choice entered please try
again...!");
}
}

}
}
3. Screenshot of Outputs:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

4. Learning Outcomes
(i) Classes
(ii)Inheritance
(iii)Switch case
(iv)Scanner-Taking input from user

You might also like