Computer-and-Information-Science / publishing-royalties
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Declaring variable
const double deliveryPrice = 5000;
const double publicationPrice = 20000;
const double netPrice_option2 = 12.5/100;
const double netPrice_option3_less_4000 = 0.10;
const double netPrice_option3_more_4000 = 0.14;
double net_Price_of_each_copy;
int estimated_copies_to_be_sold;
// input By author
std::cout << "Enter the net price of each copy of the novel: " ;
cin >> net_Price_of_each_copy;
std::cout << "Enter the estimated number of copies that will be sold: " ;
cin >> estimated_copies_to_be_sold;
std::cout << endl;
// Calculating royalties for each option
double royalties_option1 = deliveryPrice + publicationPrice;
double royalties_option2 = (netPrice_option2 * net_Price_of_each_copy * estimated_copies_to_be_sold);
double royalties_option3 = (netPrice_option3_less_4000 * net_Price_of_each_copy * std::min(estimated_copies_to_be_sold, 4000)) + (netPrice_option3_more_4000 * net_Price_of_each_copy * std::max(0, estimated_copies_to_be_sold - 4000));
// determining the best option
std::string best_option;
if (royalties_option1 > royalties_option2 && royalties_option3) {
best_option = "#1";
}
else if (royalties_option2 > royalties_option1 && royalties_option2 > royalties_option3) {
best_option = "#2";
}
else if (royalties_option3 > royalties_option1 && royalties_option3 > royalties_option2) {
best_option = "#3";
}
// output the result
std::cout << std::fixed << std::setprecision(2);
std::cout << "the expected royalties for option 1 is : " << royalties_option1 << endl;
std::cout << "the expected royalties for option 2 is : " << royalties_option2 << endl;
std::cout << "the expected royalties for option 3 is : " << royalties_option3 << endl;
std::cout << endl;
std::cout << "The best option is option " << best_option <<"." << endl;
return 0;
}