Hi Im almost finished with this code and have all the correct outputs but for some reason centgage doesn't read my code as valid. I would appreciate your help.
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.)
I am using the following code:
#include<iostream>
using namespace std;
namespace royaltyRates
{
const double ROYALTY2 = 0.125;
const double ROYALTY1 = 5000+20000;
const double ROYALTY3_1 = 0.10;
const double ROYALTY3_2 = 0.14;
}
int main()
{
double netPrice;
int numberOfCopies;
cout << "Enter the net Price of each copy: ";
cin >> netPrice;
cout << "Enter number of copies: ";
cin >> numberOfCopies;
cout << " In the first option, the author is paid $5,000 upon delivery of the final manuscript and $20,000 when the novel is published. "<<endl;
double royalty1 = royaltyRates::ROYALTY1;
cout << "Royalty from first option: " << royalty1 << endl;
cout << "In the second option, the author is paid 12.5% of the net price of the novel for each copy of the novel sold. " << endl;
double royalty2 = royaltyRates::ROYALTY2*netPrice*numberOfCopies;
cout << "Royalty from second option: " << royalty2 << endl;
cout << "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." << endl;
double royalty3 = 0;
if (numberOfCopies > 4000)
{
int copies = numberOfCopies - 4000;
royalty3 = royaltyRates::ROYALTY3_1*netPrice * 4000 + royaltyRates::ROYALTY3_2*netPrice*copies;
}
else
{
royalty3 = royaltyRates::ROYALTY3_1*netPrice*numberOfCopies;
}
cout << "Royalty from third option: " << royalty3 << endl;
//to hold the output screen
if (royalty1 > royalty2 && royalty1 > royalty3)
cout << "Option one is best."<<endl;
else if (royalty2 > royalty3 && royalty2 > royalty1)
cout << "Option second is best."<<endl;
else if (royalty3 > royalty2 && royalty3 > royalty1 )
cout << "Option third is best."<<endl;
system("pause");
return 1;
}
//output
Hi, I have tested your code and I didn't caught any problem with
it.
I run the program on different sites but none of them catching any
compile time nor runtime error.
Make sure that you're properly adding the code into Centgage
because your code is well enough.
You can check below screenshots, it runs successfully.
Hope this will help you.
Get Answers For Free
Most questions answered within 1 hours.