A new author is in the process of negotiating a contract for a new novel. The pu
ID: 3848630 • Letter: A
Question
A new author is in the process of negotiating a contract for a new novel. The publisher is offering three options: 1. The author is paid $5,000 upon delivery of the final manuscript and $20,000 when the novel is published 2. The author is paid 12.5% of the net price of the novel for each copy of the novel sold 3. The author is paid 10% of the net price for the first 4000 copies sold and 14%. of the net price for the copies sold over 4000 copies sold, for example if the author low an estimate of 7500 copies sold then the first 4000 copies the author is paid 10% and is paid 14% for the remaining 3500 copies Write a program that prompts and reads the net price for each book and the estimated number of copies that will be sold. You will compute the cost for each option and you will print out which option gives the author the largest profit along with that profit. You will output the values to two decimal places. You will also perform the following: You will perform error checking, if the user enters a negative number or something that cannot be interpreted as a valid number, output the error and terminate the program, the statement exit(0) can be used to terminate the program, so you will used to use the #include to use this function As always create named constants and variables with appropriate names and comment the variables Also comment parts of your code where you do error checking and/or calculationsExplanation / Answer
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main()
{
int copies,option;
double payment1,payment2,payment3,netPrice,highestProfit;
cout<<fixed<<setprecision(2); //display output with 2 decimal places
cout<<" Enter the net price of each book";
cin>>netPrice;
cout<<" Enter the number of copies : ";
cin>>copies;
if(copies < 0)//error checking
{
cout<<" Error: copies cannot be negative.";
exit(0);
}
//compute the payment done for each case
payment1 = 25000;
payment2 = copies * netPrice *12.5/100;
if(copies >4000)
payment3 = 4000 *1/10*netPrice + (copies- 4000)*14/100*netPrice;
else
payment3 = copies*1/10*netPrice;
//highest profit payment
if(payment1 > payment2 && payment1 > payment3)
option = 1;
else if (payment2 > payment1 && payment2 > payment3)
option = 2;
else if (payment3 > payment1 && payment3 > payment2)
option = 3;
cout<<" The option with highest profit = option "<<option;
highestProfit = (payment1>payment2)?(payment1> payment3?payment1:payment3):(payment2>payment3?payment2:payment3);
cout<<" profit = "<<highestProfit;
return 0;
}
Output:
Enter the net price of each book
Enter the number of copies :
The option with highest profit = option 1
profit = 25000.00
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.