1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alexgriva [62]
3 years ago
12

2. Using the Book class developed in HW 4, write an application, BookLibrary, that creates a library (array) of up to 10 books a

nd gives the user three options: to add a book, to delete a book from the library or to change a book’s information (i.e. number of pages and/or title) in the library. a. If the user selects the add option, issue an error message if the library is full. Otherwise, prompt the user for a book title. If the book with that title exists, issue an error message (no duplicated books titles are allowed). Otherwise, prompt the user for the number of pages and add the book. b. If the user selects the delete option, issue an error message if the library is empty. Otherwise, prompt the user for a book title. If the book with that title does not exist, issue an error message. Otherwise, "delete" (do not access the book for any future processing). c. If the user selects the change option, issue an error message if the library is empty. Otherwise, prompt the user for a book title. If the requested book title does not exist, issue an error message. Otherwise, prompt the user for a new title and/or number of pages and change the book information.
Computers and Technology
1 answer:
qwelly [4]3 years ago
6 0

BookLibrary, that creates a library (array) of up to 10 books. If the user selects the add option, issue an error message if the library is full.If the book with that title exists, issue an error message

Explanation:

import java.util.Scanner;

import java.util.Arrays;

public class Derro_BooksLibrary {

public static void main(String[] args) {

 Derro_Books[] Library = new Derro_Books[10];

 Scanner scan = new Scanner(System.in);

 Derro_Books book1 = new Derro_Books("", 20);

 Derro_Books book2 = new Derro_Books("hi", 10);

 Library[0] = book1;

 Library[1] = book2;

 System.out.println("Enter 1 for add, 2 for delete, 3 for change, 4 to stop application: ");

 int answer = scan.nextInt();

 int counter = 0;

 int z = 0;

 while (true) {

  if (answer == 1) {

   for (Derro_Books book : Library) {

    counter = counter + 1;

   }

   if (counter == 10) {

    System.out.println("Library full");

   }

   System.out.println("Enter Title: ");

   String title = scan.nextLine();

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

    if (title == Library[i].getTitle()) {

     System.out.println("No Duplicated Books Titles Are Allowed");

     break;

    }

    else {

     z++;

    }

   }

   if (z < Library.length) {

   System.out.println("Enter number of pages: ");

   int pages = scan.nextInt();

   Library[z + 1] = new Derro_Books(title, pages);

  }

  if (answer == 2){

   if (Library.length == 0) {

    System.out.println("Library is empty");

   }

   System.out.println("Enter title of book: ");

   String title2 = scan.nextLine();

   for (int d = 0; d < Library.length; d++) {

    if (title2 == Library[d].getTitle())

     // Delete book

     System.out.println("Deleted book: " + title2);

    else

     System.out.println("Book does not exist");

   }

  }

  if (answer == 3) {

   if (Library.length == 0) {

    System.out.println("Library is empty.");

   } else {

    System.out.println("Enter book title: ");

    String title3 = scan.nextLine();

    for (int y = 0; y < Library.length; y++) {

     if (title3 != Library[y].getTitle())

      continue;

     else {

      System.out.println("Enter number of pages: ");

      int pages = scan.nextInt();

      Library[y] = new Derro_Books(title3, pages);

     }

    }

   }

  }

  String[] StringList = new String[10];

  for (int y = 0; y < Library.length; y++) {

   StringList[y] = Library[y].getTitle();

  }

  Arrays.sort(StringList);

  for (String bookt : StringList) {

   System.out.println(bookt + Library);

  }

 }

}

}

}

You might be interested in
Match the appropriate color mode with the correct definition
Gemiola [76]

Answer:

1.RGB: Best for projects intended to be used on the web or video

Explanation:

On websites or making project RGB combination of colors is used. This combination of colors is used to store images in electronic components.

2. CMYK: best for professional printing projects using process colors

Explanation:

Printing professional use CMYK combinations of color for better printing results.

3.) indexed:The only colors saved are the colors used in the image

To manage digital images we use Indexed mode of colors.

Explanation:

4.) bitmap: uses black and white

Explanation:

bitmap is the combination of the black and white colors. As the images are large in size so that, to reduce the size of the image we store image in bitmap to reduce the size.

5.) gray scale: uses different shades of grey

Explanation:

The different shades of gray colors are found in the gray scale. These shades are used to produce images.

4 0
3 years ago
What is Digital Access, and why is it important for YOUR generation?
Harman [31]

“Our students were born with a mouse in their hands. The pervasive nature of digital culture has altered the way they think, and the way they learn. Education today is completely out of sync with this new reality.” an excerpt from Understanding the Digital Generation. The New ConnectionsThis eye-opening presentation provides a comprehensive look at how the pervasive nature of digital culture has and continues to change the brains of our students. As a result of these changes, they have developed learning styles and preferences which are in contrast to the traditional pedagogical approach. The New Connections provides a clear description of 10 core learning attributes of digital learners, and a pragmatic look at how we can teach effectively in an age when new technologies cascade onto the new digital landscape at an astonishing rate. Because of digital bombardment and the emergence of the new digital landscape, today’s youth process information, interact and communicate in fundamentally different ways than any previous generation before them. Meanwhile, many of us, having grown up in a relatively low-tech, stable, and predictable world, are constantly struggling with the speed of change, technological innovation, and the freedom to access the overwhelming sea of information online—all defining characteristics of the digital world of both today, and the swiftly-approaching future. Strategies That Work provides a comprehensive profile of several core learning attributes of digital learners, and the core teaching, learning, and assessment strategies that can be used to appeal to their digital lifestyle and learning preferences. You’ll gain a clear understanding of various research-based strategies to optimize learning for the digital generation in the new digital landscape.

7 0
3 years ago
Plz help ( which is an example of a good URL?
Simora [160]

The answer is B because it is short and simple and gets you to the point

8 0
4 years ago
Read 2 more answers
What influential work about the Vietnam war was written by Tim O Brien
MArishka [77]
- Question -

What influenced work about the Vietnam War was written by Tim O Brian?

- Answer -

The Things They Carried

______________________________________________


These were a series of short stories O Brien wrote including in these stories his experiences with the Vietnam War



\boxed{ -  \ The \ Wolf  \  -}

4 0
3 years ago
Computers can accomplish many tasks today, but there are still some things they cannot do. Think of some of the things you would
postnew [5]
Record our dream.
Since it is from the future and advanced, it is invalid to argue back that the wish to record our dreams cannot be fulfilled.

From here you can elaborate more ...
7 0
3 years ago
Other questions:
  • Explain what all sensory receptors have in common.
    14·1 answer
  • A web designer must effectively communicate when he/she designs a web page. If there is too much information to put onto one pag
    8·1 answer
  • Analytical processing uses multi-levelaggregates, instead of record level access.? True? False
    12·1 answer
  • Written and artistic expressions are protected by
    8·1 answer
  • A student is curious about how a Web site appears on his computer screen. On a piece of paper,
    9·1 answer
  • What command would you use to add a file to an e-mail message?
    15·2 answers
  • Suppose you are an ad-serving company and you maintain a log of cookie data for ads you serve to the Web pages for a particular
    14·1 answer
  • Is anyone else excited for sephiroth (I think I spelt it wrong) in smash. And if you arn't are you excited for christmas
    12·1 answer
  • JAVA
    12·1 answer
  • Which option should you choose to change the background of your current slide?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!