FictionBook RankingYou are tasked with creating a program foraddingFiction Books library ranking.Each book willhave a name, genre,...



















FictionBook Ranking






You are tasked with creating a program for








adding








Fiction Books library ranking


.








Each book will






have a name, genre, number of copies sold, and percent


age








sold.








You will also








determine the total






number of books added and the total number of all books sold


.






Requirements















Create two Classes, a driver class called BookRanking, and a class








Fiction


Book















FictionBoo


k








will have following parameters and are all private:






1.








Name






2.








Number of copies sold






3.








Genre






4.








Percentage of books sold






5.








Total Number of books added, it must be a static variable






6.








Total Number of books sold for all books, it must be a static variable















FictionBook mus


t have these user


-


defined








Non


-


Static








methods






1.








Method to get total number of books added






2.








Method to get total number of books sold for all books






3.








Methods for all private parameters (getters and setters)






4.








Don’t create methods for setting number of books added or








total number of book sold















FictionBook must this Overloaded Constructor






1.








It will accept only, the name and number of copies sold as parameters.






2.








Hint, you will need to have the static parameters here






3.








Hint, the genre will be set using a method















BookRanking can have as many parameters as needed















BookRanking will have method main which will have this








non


-


static








object:






1.








FictionBook[] books = new FictionBook[5];















BookRanking must have these user


-


defined








Static








methods






1.








Method to create








an








array of books








-








All user inputs must be done in this method






2.








Method to determine the percent


age








sold and it add to the array






3.








Method to print the results








-








results retrieved via loop and getter methods.















Use this template for the








print method


:






private static void printResults(


An array of FictionBook


) {






String sStars = String.format("%73s", " ").replace(' ', '*');






System.out.printf("%n%s", sStars);






System.out.printf("%n| %


-


20s | %


-


20s | %


-


12s |








%


-


12s", "Name ","Genre", "Books






Sold", "Percentage");






For loop






System.out.printf("%n| %


-


20s | %


-


20s | %


-


12d | %


-


12.2f",








Value for Name


,








Value






for Genre


,








Value for Copies sold


,








Value for Percent Sold








);






End of For Loop






System.


out.printf("%n%s%n", sStars);






System.out.println("The total number of books: " +








Value for number of books


);






System.out.println("The total number of books sold: " +








Value for total number of






books sold


);






}




































































2






Input:















Your program








will








prompt the user








for each to


:






o








Enter








the








book Name:






o








Enter the Genre:






o








Enter the number of copies sold:






Data Inputted:















Book 1






o








Rings of the Lords






o








Rings






o








305















Book 2






o








Hungry Games






o








Dystopia






o








211















Book 3






o








Magic School






o








Spells






o








389















Book 4






o








Thrones and Games






o








Dragons






o








183















Book 5






o








The Moving Tower






o








Portals






o








266






Output:















*************************************************************************















| Name








| Genre








| Books Sold








| Percentage















| Rings of the Lords








| Rings








| 305








| 0.


23















| Hungry Games








| Dystopia








| 211








| 0.1


6















| Magic School








| Spells








| 389








| 0.2


9















| Thrones and Games








| Dragons








| 183








| 0.1


4















| The Moving Tower








| Portals








| 266








| 0.


20















*************************************************************************















The total numb


er of books:








5















The total number of books sold:








1354














Mar 26, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here