0% found this document useful (0 votes)
27 views

Java Program

book program

Uploaded by

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

Java Program

book program

Uploaded by

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

import java.util.

Scanner;
class Book
{
int id, no_of_copies;
String author;
String title;
float price;
public void putData()
{
Scanner s = new Scanner(System.in);
System.out.println("Enter book ID: ");
id = Integer.parseInt(s.nextLine());
System.out.println("Enter author name: ");
author= s.nextLine();
System.out.println("Enter no_of_copies: ");
no_of_copies = s.nextInt();
System.out.println("Enter the title");
title = s.nextLine();
System.out.println("Enter the price");
price = s.nextFloat();
}
public void getData()
{
System.out.println("BookID: " + id);
System.out.println("AuthorName: " + author);
System.out.println("No_of_Copies: " + no_of_copies);
System.out.println("Title" + title);
System.out.println("Price:" + price);
}
}
class Exam13
{
public static void main(String []args)
{
Book[] pss = new Book[5];
for(int i=0;i<5;i++)
{
System.out.println("Enter the Details: " + i + "book");
pss[i].putData();

}
System.out.println("Details of books are: ");
for(int i=0;i<5;i++)
pss[i].getData();
}
}

You might also like