Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program 1 Two files are required, a data class named Book and an executable class named TestBook. Class Book - has instance data members (all
Program 1 Two files are required, a data class named Book and an executable class named TestBook. Class Book - has instance data members (all private) String title, String author, int pages, double price. - has a public static int variable named numBooks with an initial value of zero. - has a parameterized constructor that will be used to make a Book object and assign values to its data members, and increment numBooks. - has a no-arg constructor that increments numBooks. - has getters and setters for all instance data members. - has a toString() method that returns a string displaying the state of a Book instance. - Use the numBooks variable to report the number of books instantiated. Class TestBook This class needs a main method and two more methods. In main: 1. create an array capable of holding six Book objects. 2. use the parameterized constructor to specify the data in the first four elements of this array 3. use the no-arg constructor to create the two remaining books in the array. 4. process the array with a foreach loop to display the array at this point. 5. call the finishArray0 method with the array as the only argument. 6. call the reduceBooks() method with the array as the sole argument. 7. repeat the code needed by Step 4 above. 8. display the most expensive book after the discounts. In finishArrayd): 1. this is a void method. 2. use the setter methods to specify the data in all fields of the last two books in the array. In reduceBooks(): 1. this method returns a Book instance. 2. use a loop (any type) to reduce the price of every book in the array by 40%. 3. determine the most expensive book after the discounts and return this book to main. SAMPLE OUTPUT Book t1tle-Java Programing, author-L1ang, pages-1320, price $145.00 Book title=Horton Hears a Who!, author=Dr. Seuss, pages =72, price =$19.99 Book title-The Hobbit, author-Tolklen, pages-320, price =$9.25 Book title=Born a Crine, author=Noah, pages=364, price =$17.33 Book title=nu11, author=nu11, poges-6, price =50,00 Book title=null, author=null, pages =0, price =$0.00 Books after completing lbrary and 46% discount Book title-Java Programming, author-Liang, pages-132e, price - $87.00 Book title-Horton Hears a Whol, author-Dr. Seuss, pages-72, price - $11.99 Book title=The Hobbit, author=Tolkien, pages=32e, price =$5.55 Book title-Born a Crine, author-Noah, pages-364, price - $10.46 Book title=Dark Territory, author=Kaplan, pages =352, price =$11.24 Book title-Born to Run, author-5pringsteen, pages-508, price = $12.17 Here is the most expensive book after the discounts Book title=Java Programming, author=Liang, pages =1320, price =$87.00 Size of library: 6 books Program 2 Write a Java program that prompts the user to enter a password that matches a specific pattern using a single regex statement as covered in your textbook. Your program must approve the user's entry.. Here is the pattern, in this order: - 1 or more upper case letters - two lower case letters - 1 or 2 digits - zero or 1 upper case letters - any two of this group @\#\# $%&
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started