Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Java Publisher -name:String state String Book -title String -author String

ID: 3838770 • Letter: U

Question

Using Java Publisher -name:String state String Book -title String -author String -publisher:Publisher Due March 10 by ll:59 pm. -price:double Even though the UML isnot complete, you will write the complete code for cach class. It adheres to our coding standards. +calculateCharge (quantity:int):double Fiction NonFiction -fictionCode int -category Code: String Write the classes using our coding standards. Write Book System, the main program. It will declare a two-dimensional array of String data, data Array, as follows: Fiction, Abraham Lincoln Vampire Hunter, Grahame-Smith, Wiley, NY, 13.99, 222 Fiction, Frankenstein, Shelley, Prescott, GA, 7.99, 321 NonFiction, Life of Kennedy, Jones, Pearson, MT, 12.90, biography Fiction, Dracula. Stoker, Addison. CA. 5.99. 145 Fiction. Curse of the Wolfman, Hageman, Wesley, MA, 10.59, 876 NonFiction. How to Pass Java, Willis, Wiley. NY. 1.99, technology Fiction, The Mummy, Rice, Addision, CA. 7.99, 954 NonFiction, History of Texas, Smith, Prescott, CA, 9.75, history An array, quantityArray, will be declared as int and hold 12 83 3 53 7 23 14 5 Using dataArray, you will create the book instances and store them in bookArray. Using the quantity array, walk through bookArray and call calculateCharge for the total charges per book sold. Print in a dialog box the book title and the total charge for each book and then print the grand total of all books sold. Format money. Zip the entire BookSystem project in NetBeans and upload to BB

Explanation / Answer

This is Publisher class

package com.bookstore;

public class Publisher {

   String name;
   String state;
   public Publisher() {
       super();
       // TODO Auto-generated constructor stub
   }
   public Publisher(String name, String state) {
       super();
       this.name = name;
       this.state = state;
   }
  
}

This is BooK class

package com.bookstore;

public class Book {

   String title;
   String auther;
   Publisher publisher;
   Double price;
  
  
   int quantity;
   String categoryCode;
   int fictionCode;
  
   public Book() {
       super();
       // TODO Auto-generated constructor stub
   }
  


   public Book(String categoryCode,String title, String auther, Publisher publisher, Double price,int quantity) {
       super();
       this.categoryCode=categoryCode;
       this.title = title;
       this.auther = auther;
       this.publisher = publisher;
       this.price = price;
       this.quantity = quantity;
   }

   public Double calculateCharge(int quantity){
       Double charge=0.0;
       charge=charge+quantity*price;
       return charge;
   }
}

This is main BookSystem Class

package com.bookstore;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class BookSystem {
  
   public static void main(String[] args) {
       // TODO Auto-generated method stub

       Double total=0.0;
       List<Book> list=new ArrayList<Book>();
      
      
       Publisher publisher=new Publisher("Grame Smith", "Willy,NY");
       Publisher publisher1=new Publisher("Prescott", "GA");
       Publisher publisher2=new Publisher("Pearson", "MT");
       Publisher publisher3=new Publisher("Adision", "CA");
       Publisher publisher4=new Publisher("Wesly", "MA");
       Publisher publisher5=new Publisher("Willy", "NY");
       Book bk=new Book("Fiction","Abrhankan linkan", "Vapire Hunter", publisher, 15.0, 10);
       Book bk1=new Book("Fiction","Frankenstien", "shelly", publisher1, 15.0, 10);
       Book bk2=new Book("NonFiction","Life of kenidy", "Jone", publisher2, 15.0, 10);
       Book bk3=new Book("Fiction","Dracula", "Stoker", publisher3, 15.0, 10);
       Book bk4=new Book("Fiction","Curse of Wolfman", "Hageman", publisher4, 15.0, 10);
       Book bk5=new Book("NonFiction","How to pass java", "wilis", publisher5, 15.0, 10);
      
      
       list.add(bk);
       list.add(bk1);
       list.add(bk2);
       list.add(bk3);
       list.add(bk4);
       list.add(bk5);

       Iterator<Book> itr=list.iterator();
       while(itr.hasNext()){
           Book str=(Book)itr.next();
          
           System.out.print(str.categoryCode+","+str.title+","+str.auther+",");
          
           Publisher p=str.publisher;
           System.out.print(p.name+","+p.state+",");
           System.out.println("$"+str.price);
           total=total+str.calculateCharge(str.quantity);
       }
      
       System.out.println("Grand Total:$"+total);
   }

}

Output:

Fiction,Abrhankan linkan,Vapire Hunter,Grame Smith,Willy,NY,$15.0
Fiction,Frankenstien,shelly,Prescott,GA,$15.0
NonFiction,Life of kenidy,Jone,Pearson,MT,$15.0
Fiction,Dracula,Stoker,Adision,CA,$15.0
Fiction,Curse of Wolfman,Hageman,Wesly,MA,$15.0
NonFiction,How to pass java,wilis,Willy,NY,$15.0
Grand Total:$900.0

I can't upload project zip file this facility not available.

Please copy paste above code in net beans it will work

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote