0% found this document useful (0 votes)
35 views1 page

Java Program

The document contains a Java program that defines a 'Book' class with methods to input and display book details such as ID, author, number of copies, title, and price. The 'Exam13' class creates an array of 'Book' objects, prompts the user to input details for five books, and then displays the entered details. However, the program has an issue as the 'Book' objects in the array are not instantiated before use.

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)
35 views1 page

Java Program

The document contains a Java program that defines a 'Book' class with methods to input and display book details such as ID, author, number of copies, title, and price. The 'Exam13' class creates an array of 'Book' objects, prompts the user to input details for five books, and then displays the entered details. However, the program has an issue as the 'Book' objects in the array are not instantiated before use.

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