Question

In: Computer Science

Today BandN book stores is currently running a deal on e-books. Customers will receive a 15%...

Today BandN book stores is currently running a deal on e-books. Customers will receive a 15% discount off their entire order. Customers who buy 20 or more e-books will receive 20% off instead. Each book costs a flat $8.99. Write a C++ program that will calculate the final cost of your order, using functions. Global variables are not allowed unless they are constant. Information should be passed with parameters. Your main function should not do any of the tasks in the list below. The program will print a set of instructions for the user and give a brief explanation of the purpose. It will ask the user for the number of books you wish to download. It will display the number of books to be downloaded, the subtotal for the books, the discount earned and the total cost for the books. You should write a user-defined function to perform each of the following tasks: • print the instructions • prompt and read the number of books to be downloaded • calculate the sub total for those books • calculate the discount for your order • calculate the total cost for the downloaded books • print the results in a neat and well-labeled form

Solutions

Expert Solution

#include<bits/stdc++.h>
using namespace std;

const double discount1 = 0.15;
const double discount2 = 0.20;
const double book_price_per_peice = 8.99;
void print_the_instructions(){
    cout<<"Welcome to BandN book store\n"<<
          "1. Each book cost $8.99\n"<<
          "2. 15\% discount on entire order\n"
          "3. 20\% discount on if you buy 20 or more books\n";
}

void number_of_book_to_be_downloaded(int& n){
    cout<<"How many books will be downloaded?: ";
    cin>>n;
    cout<<endl;
}

void calculate_subtotal(int n,double& total){

     total = n*book_price_per_peice;
}

void discount20(int n,double& total){
        if(n>=20)
        total += n*discount2;
}

void discount15(int n,double& total){
        if(n<20)
        total += n*discount1;
}
void print_result(int n,double total){
    cout<<"Total cost = "<<total<<endl<<
          "Total books puchased = "<<n<<endl<<
          "Discount applied = "<<(n>=20?20:15)<<endl;

}
int main(){
    print_the_instructions();
    int n;
    double total = 0;
    number_of_book_to_be_downloaded(n);
    calculate_subtotal(n,total);
    discount15(n,total); 
    discount20(n,total); 
    print_result(n,total);
}


Related Solutions

Mira’s Book distributes books to retail stores and extends credit terms of 2/15 n/30 to all...
Mira’s Book distributes books to retail stores and extends credit terms of 2/15 n/30 to all of its customers. At the end of May, Mira’s inventory consisted of 100 books purchased for @ of $18 total of $1,800. During June, the following merchandising transactions occurred.And they are following periodic inventory system. June 1 Purchased 32 books on account for @ of $50 total of $1,600 from Bondhu Publishers, FOB destination, terms 2/4, n/30. The appropriate party also made a cash...
You are running a Book shop where you are keeping inventory for all the books. Design...
You are running a Book shop where you are keeping inventory for all the books. Design a program with the following interface using javafx scene builder, File IO and ArrayList class. Following GUI is just an example choose different color, design and font for your GUI interface. Write program which allows you to enter book name, author, price of each book and number of books in stock of the book through textboxes and store it in arraylist. Write button reads...
Bridgeport Book Warehouse Ltd. distributes hardcover books to retail stores. At the end of May, Bridgeport’s...
Bridgeport Book Warehouse Ltd. distributes hardcover books to retail stores. At the end of May, Bridgeport’s inventory consists of 260 books purchased at $ 16each. Bridgeport uses a perpetual inventory system. During the month of June, the following merchandise transactions occurred: June 1 Purchased 180 books on account for $ 14 each from Reader’s World Publishers, terms n/45. 3 Sold 210 books on account to The Book Nook for $ 25 each, with an assumed average cost of $ 15,...
Sheffield Book Warehouse Ltd. distributes hardcover books to retail stores. At the end of May, Sheffield’s...
Sheffield Book Warehouse Ltd. distributes hardcover books to retail stores. At the end of May, Sheffield’s inventory consists of 230 books purchased at $ 17 each. Sheffield uses a perpetual inventory system. During the month of June, the following merchandise transactions occurred: June 1 Purchased 160 books on account for $ 15 each from Reader’s World Publishers, terms n/45. 3 Sold 220 books on account to The Book Nook for $ 25 each, with an assumed average cost of $...
You are currently negotiating a book publishing deal on behalf of your client, K.J. Howling, a...
You are currently negotiating a book publishing deal on behalf of your client, K.J. Howling, a writer of moderate repute who specializes in horror stories. Your client is basically happy with the standard form contract offered by the publisher, Scattered House Press (SHP). There is, however, an important exception. Howling would like to have a clause removed from the contract under which SHP would have automatic rights to publish any sequel, on the same royalty terms as the contract now...
P5-2A Phantom Book Warehouse Ltd. distributes hardcover books to retail stores. At the end of May,...
P5-2A Phantom Book Warehouse Ltd. distributes hardcover books to retail stores. At the end of May, Phantom's inventory consists of 250 books purchased at $18 each. Phantom uses a perpetual inventory system. During the month of June, the following merchandise transactions occurred: June  1 Purchased 180 books on account for $16 each from Reader's World Publishers, terms n/45. 3 Sold 220 books on account to The Book Nook for $25 each, with an average cost of $17, terms 2/10, n/45....
Blue Spruce’s Book Warehouse distributes hardcover books to retail stores and extends credit terms of 2/10,...
Blue Spruce’s Book Warehouse distributes hardcover books to retail stores and extends credit terms of 2/10, n/30 to all of its customers. At the end of May, Blue Spruce’s inventory consisted of books purchased for $1,600. During June, the following merchandising transactions occurred. June 1 Purchased books on account for $1,400 from Kline Publishers, FOB destination, terms 2/10, n/30. The appropriate party also made a cash payment of $50 for the freight on this date. 3 Sold books on account...
Problem 5-1A Kern’s Book Warehouse distributes hardcover books to retail stores and extends credit terms of...
Problem 5-1A Kern’s Book Warehouse distributes hardcover books to retail stores and extends credit terms of 1/10, n/30 to all of its customers. At the end of May, Kern’s inventory consisted of books purchased for $2,400. During June, the following merchandising transactions occurred. June 1 Purchased books on account for $2,100 from Binsfeld Publishers, FOB destination, terms 2/10, n/30. The appropriate party also made a cash payment of $60 for the freight on this date. 3 Sold books on account...
Amazon had a public dispute with the book publisher Hachette regarding its prices for e-books. Amazon...
Amazon had a public dispute with the book publisher Hachette regarding its prices for e-books. Amazon was trying convince Hachette to lower their price for e-books, arguing that doing so would benefit both consumers and the publisher; Hachette was refusing to cut their prices, countering that lower prices would hurt both the publisher and their authors. Amazon explained their objectives in terms of price elasticity on their discussion board which they recently discontinued. The full post was e-mailed to the...
3. (15 marks) a. Design a simple normalized Library database for tracking “customers reserve books” with...
3. a. Design a simple normalized Library database for tracking “customers reserve books” with not more than 3 tables and answer the following questions about your database. b. Discuss how your database is in third normal form using functional dependencies (FDs). c. Create an instance of your database. d. Provide one external level view query in English on your database.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT