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

The Educated Bookstore Company has asked you to help them write a Book Purchasin

ID: 3592419 • Letter: T

Question

The Educated Bookstore Company has asked you to help them write a Book Purchasing System (BPS). The system can be used to store information about books, customers, members, and selling records (books already bought by a customer/member). A customer is a person who buy books from the bookstore while a member is a VIP customer who are given discount when buys books.

The following data about books (ISBN, Title, Author, Price) are saved in a file book.txt:

5-17-525281-3 C++ Programing, Davender Malik, 210

3-7908-1335-4 Discrete Structures, Davender Malik, 185

3-7908-1325-7 Fuzzy Mathematic, Davender Malik, 165

0-239-23635-0 Data Structures, Shih-Chung Cheng, 240

2-99521-453-1 Introduction to Web Programming, Mark Headington, 130

0-521-43681-8 English Grammar in Use, Raymond Murphy, 75

0-7637-8060-x JavaScript, John David Dionisio, 155

0-201-40015-4 Calculus and Analytic geometry, George B. Thomas, 280

0-19-431735-1 Oxford Wordpower, Oxford University, 37

0-86134-022-1 The Camera Book, Mitcheil Beazley, 45

The following data about customers/members (ID, Name, email, number of books) are saved in a file customer.txt, only the ISBNs are saved:

912345678 Saleh Al-Yaaroubi, 912345678@abc.ac.ae, 8

0-239-23635-0 2-99521-453-1 0-521-43681-8 0-7637-8060-x

3-7908-1335-4 0-201-40015-4 0-19-431735-1 3-7908-1325-7

567891234 Khaulah Al-Lawati, 567891234@abc.ac.ae, 1

0-521-43681-8

234567891 Amal Al-Waili, 234567891@abc.ac.ae, 4

0-7637-8060-x 0-201-40015-4 3-7908-1325-7 0-239-23635-0

345678912 Sharifa Al-Mahroqi, 345678912@abc.ac.ae, 7

3-7908-1335-4 5-17-525281-3 0-7637-8060-x 0-19-431735-1

0-521-43681-8 0-86134-022-1 3-7908-1325-7

789123456 Arif Al-Waili, 789123456@abc.ac.ae, 6

3-7908-1325-7 2-99521-453-1 0-521-43681-8 5-17-525281-3

0-86134-022-1 0-201-40015-4

891234567 Abdullah Al-Harthi, 891234567@abc.ac.ae, 3

0-19-431735-1 3-7908-1325-7 0-7637-8060-x

132456789 Talal Al-Zidjali, 132456789@abc.ac.ae, 6

0-521-43681-8 0-19-431735-1 5-17-525281-3 0-201-40015-4

0-86134-022-1 3-7908-1325-7

123456789 Taghreed Al-Saadi, 123456789@abc.ac.ae, 3

2-99521-453-1 5-17-525281-3 0-19-431735-1

678912345 Suleiman Al-Lawati, 678912345@abc.ac.ae, 4

2-99521-453-1 3-7908-1335-4 0-86134-022-1 0-521-43681-8

456789123 Suad Al-Saadi, 456789123@abc.ac.ae, 2

0-239-23635-0 0-19-431735-1

Problem #1:

Define a struct called book that has the components (ISBN, title, author, and price).

Problem #2:

Define a class called Customer that has the private members (ID, name, email, numberOfBooks, an array books[ ] of type book, totalCost) and the function calculateCost( ) that finds the total cost of bought books. The class has the public members set( ), print( ), getTotalCost( ), and a default parametrized constructor.

Implement all member functions of the class.

Problem #3:

Define a class called Member which publicly inherits the class Customer and has the private members discount, netCost, and the function calculateNetCost( ). The class has the public members set( ), print( ), and a default parametrized constructor.

Implement all member functions of the class.

Use the following driver:

int main()

{

   Customer w("789123456");

    Member VIP("789123456", 20);

    w.print();

    VIP.print();

    return 0;

}

789123456 Arif Al-Waili 789123456@abc.ac.ae Bought the following 6 books 3-7908-1325-7 Fuzzy Mathematic 2-99521-453-1 Introduction to Web Programming 0-521-43681-8 English Grammar in Use 5-17-525281-3 C++ Programing 0-86134-022-1 The Camera Book 0-201-40015-4 Calculus and Analytic geometry Davender Malik Mark Headington Raymond Murphy Davender Malik itchell Beazley George B. Thomas The cost of the above books is 905 dirhams 789123456 Arif Al-Waili 789123456@abc.ac.ae Bought the following 6 books 3-7908-1325-7 Fuzzy Mathematic 2-99521-453-1 Introduction to Web Programming 0-521-43681-8 English Grammar in Use 5-17-525281-3 C++ Programing 0-86134-022-1 The Camera Book 0-201-40015-4 Calculus and Analytic geometry Davender Malik Mark Headington Raymond Murphy Davender Malik Mitcheil Beazley George B. Thomas The cost of the above books is 905 dirhams This customer is a member and has a 20% discount The net cost of this member is 724 dirhams

Explanation / Answer

class Book{
// fields
public String isbn;
public String title;
public String author;
public double price;
/**
* @param isbn the isbn to set
*/
public void setIsbn(String isbn){
this.isbn = isbn;
}
/**
* @returns the isbn
*/
public String getIsbn(){
return isbn;
}


/**
* @param title the title to set
*/
public void setTitle(String title){
this.title = title;
}
/**
* @returns the title
*/
public String getTitle(){
return title;
}


/**
* @param author the author to set
*/
public void setAuthor(String author){
this.author = author;
}
/**
* @returns the author
*/
public String getAuthor(){
return author;
}

/**
* @param price the price to set
*/
public void setPrice(double price){
this.price = price;
}
/**
* @returns the price
*/
public double getPrice(){
return price;
}

class Customer {
private String ID;
private String name;
private String email;
private String numberOfBooks;
private double totalCost;
private ArrayList <Book> typeOfBook;

Book book = new Book();

public void setBook(Book book){

this.book = book;

}

public Book getBook(){

return book;

}

private double calculateCost( ){

BufferedReader br = new BufferedReader(new FileReader("book.txt"));

try {

StringBuilder sb = new StringBuilder();

String line = br.readLine();

while line!= null) {

sb.append(line);

sb.append(System.lineSeparator());

line = br.readLine();

}

String everything = sb.toString();

String [] bookData = everything.split(",");

book.setIsbn(bookData[0]); //0 for isbn

book.setTitle(bookData[0]); //1 for title ,

book.setAuthor(bookData[0]);// 2 for author

book.setPrice(bookData[3]);//3 for price

this.bookTypes.add(book);

this.getTotalCost(bookTypes);

} catch(Exception e){

e.printstacktrace()

}finally {

br.close();

}

}

getTotalCost(bookTypes){

while(bookType.size() > 0 ){

this.totalCost = totalCost + this.bookType.book.getPrice();

bookType.size()-1;

}

return totalCost;

}

}

class Member extends Customer {

public int discount;

public double netCost;

public double calculateNetCost(totalcost ,discountpercentage){

double discount = totalCost*discountpercentage/100;

netCost = totalcost - discount ;

return netCost;

}

}

public class BookBilling{

public static void main(String []args) {

billing(){

Customer calculateCost("789123456",0);

Member calculateCost("789123456",20);

}

}

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