Respuesta :

An array is a type of data structure that consists of a set of elements (values or variables), each of which is designated by an array index or key.

What is a data structure?

In order to organize, process, retrieve, and store data, a data structure is a specific format. Data structures come in a variety of basic and sophisticated forms and are all made to organize data in a way that is appropriate for a particular function. Users can quickly access and use the data they require in the right ways thanks to data structures. The organization of information is framed by data structures in a way that makes it easier for machines and people to understand.

An application named bookarray in which we create an array that holds 10 books, some fiction and some nonfiction. using a for loop, we will display details about all 10 books. save the file as bookarray.java.

public class BookArray

{

   //start main method

   public static void main(String[] args)

   {

       //create an array to store 10 books

       Book books[] = new Book[10];

       //create and store 5 Fiction objects

       books[0] = new Fiction("The First Animals");

       books[1] = new Fiction("And Then There Were None");

       books[2] = new Fiction("The Grim Reaper");

       books[3] = new Fiction("Spirited Away");

       books[4] = new Fiction("Inception");

       //create and store 5 NonFiction objects

       books[5] = new NonFiction("In Cold Blood");

       books[6] = new NonFiction("Silent Spring");

       books[7] = new NonFiction("A Room of One's Own");

       books[8] = new NonFiction("When Breath Becomes Air");

       books[9] = new NonFiction("The Tipping Point");

       //display the details of all books

       System.out.println("Details of all the books:");

       for(int i = 0; i < books.length; i++)

       {

           System.out.println();

           System.out.println((i + 1) + ".Name:" +

                   books[i].getBookTitle());

           System.out.println("Price:$"+ books[i].getBookPrice());

       }//end for

   }//end of main method

}//end of BookArray class

class Book{

   private String bookTitle;

   private double bookPrice;

   public Book(String title){

       this.bookTitle = title;

       bookPrice = 43.54;

   }

   public String getBookTitle() {

       return bookTitle;

   }

   public double getBookPrice() {

       return bookPrice;

   }

}

class Fiction extends Book{

   public Fiction(String title) {

       super(title);

   }

}

class NonFiction extends Book{

   public NonFiction(String title) {

       super(title);

   }

}

/*

Sample run:

Details of all the books:

1.Name:The First Animals

Price:$43.54

2.Name:And Then There Were None

Price:$43.54

3.Name:The Grim Reaper

Price:$43.54

4.Name:Spirited Away

Price:$43.54

5.Name:Inception

Price:$43.54

6.Name:In Cold Blood

Price:$43.54

7.Name:Silent Spring

Price:$43.54

8.Name:A Room of One's Own

Price:$43.54

9.Name:When Breath Becomes Air

Price:$43.54

10.Name:The Tipping Point

Price:$43.54

*/

Learn more about data structure

https://brainly.com/question/13147796

#SPJ4