Question: Instructions Redo Programming Exercise 1 6 of Chapter 4 so that all the named constants are defined in a namespace royaltyRates. Instructions for Programming Exercise

Instructions Redo Programming Exercise 16 of Chapter 4 so that all the named constants are defined in a namespace royaltyRates.
Instructions for Programming Exercise 16 of Chapter 4 have been posted below for your convenience.
Exercise 16 A new author is in the process of negotiating a contract for a new romance novel. The publisher is offering three options. In the first option, the author is paid $5,000 upon delivery of the final manuscript and $20,000 when the novel is published. In the second option, the author is paid 12.5% of the net price of the novel for each copy of the novel sold. In the third option, the author is paid 10% of the net price for the first 4,000 copies sold, and 14% of the net price for the copies sold over 4,000. The author has some idea about the number of copies that will be sold and would like to have an estimate of the royalties generated under each option. Write a program that prompts the author to enter the net price of each copy of the novel and the estimated number of copies that will be sold. The program then outputs the royalties under each option and the best option the author could choose. (Use appropriate named constants to store the special values such as royalty rates and fixed royalties.)
this is the code i have so far:
#include
#include
#include
namespace royaltyRates {
const double OPTION1_DELIVERY_PAYMENT =5000.0;
const double OPTION1_PUBLICATION_PAYMENT =20000.0;
const double OPTION2_ROYALTY_RATE =0.125;
const double OPTION3_BASE_ROYALTY_RATE =0.10;
const double OPTION3_ADDITIONAL_ROYALTY_RATE =0.14;
const int OPTION3_THRESHOLD =4000;
}
double calculateOption1Royalties(){
return royaltyRates::OPTION1_DELIVERY_PAYMENT + royaltyRates::OPTION1_PUBLICATION_PAYMENT;
}
double calculateOption2Royalties(double netPrice, int copiesSold){
return netPrice * copiesSold * royaltyRates::OPTION2_ROYALTY_RATE;
}
double calculateOption3Royalties(double netPrice, int copiesSold){
double baseRoyalties = netPrice * std::min(copiesSold, royaltyRates::OPTION3_THRESHOLD)* royaltyRates::OPTION3_BASE_ROYALTY_RATE;
double additionalRoyalties =0.0;
if (copiesSold > royaltyRates::OPTION3_THRESHOLD){
additionalRoyalties = netPrice *(copiesSold - royaltyRates::OPTION3_THRESHOLD)* royaltyRates::OPTION3_ADDITIONAL_ROYALTY_RATE;
}
return baseRoyalties + additionalRoyalties;
}
int main(){
double netPrice;
int copiesSold;
std::cout << "Enter the net price of each copy of the novel: ";
std::cin >> netPrice;
std::cout << "Enter the estimated number of copies that will be sold: ";
std::cin >> copiesSold;
double option1Royalties = calculateOption1Royalties();
double option2Royalties = calculateOption2Royalties(netPrice, copiesSold);
double option3Royalties = calculateOption3Royalties(netPrice, copiesSold);
std::cout << std::fixed << std::setprecision(2);
std::cout << "Royalty option1: "<< option1Royalties << std::endl;
std::cout << "Royalty option2: "<< option2Royalties << std::endl;
std::cout << "Royalty option3: "<< option3Royalties << std::endl;
double maxRoyalties = std::max({option1Royalties, option2Royalties, option3Royalties});
if (maxRoyalties == option1Royalties){
std::cout << "The best option is Option 1."<< std::endl;
} else if (maxRoyalties == option2Royalties){
std::cout << "The best option is Option 2."<< std::endl;
} else {
std::cout << "The best option is Option 3."<< std::endl;
}
return 0;
}
and this is the error code that i cant figure out how to get around. the first and third tasks pass, just not number 2.
Status: FAILED!
Check: 2
Test: Successful Output II
Reason: Unable to find '['Royalty option1: 25000.00', 'Royalty option2: 771604931.25', 'Royalty option3: 864189523.00']' in the program's output.
Enter the net price of each copy of the novel: Enter the estimated number of copies that will be sold: Royalty option1: 25000.00
Royalty option2: 771604931.25
Royalty option3: 617283945.00
The best option is Option 2.
.
Error : AssertionError - Unable to find Royalty option3: 864189523.00 in the program's output.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!