Question

Hi Im almost finished with this code and have all the correct outputs but for some...

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

Homework Answers

Answer #1

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++...
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++ 11. Write a function that will merge the contents of two sorted (ascending order) arrays of type double values, storing the result in an array out- put parameter (still in ascending order). The function shouldn’t assume that both its input parameter arrays are the same length but can assume First array 04 Second array Result array that one array doesn’t contain two copies of...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...