Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Redo Programming Exercise 1 6 of Chapter 4 so that all the named constants are defined in a namespace royaltyRates. Instructions for Programming Exercise 1
Redo Programming Exercise of Chapter so that all the named constants are defined in a namespace royaltyRates.
Instructions for Programming Exercise of Chapter have been posted below for your convenience.
Exercise
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 $ upon delivery of the final manuscript and $ when the novel is published. In the second option, the author is paid of the net price of the novel for each copy of the novel sold. In the third option, the author is paid of the net price for the first copies sold, and of the net price for the copies sold over 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.
Task #: Program Executes Correctly
This is the code i have so far:
#include
#include
#include
using namespace std;
Define the namespace royaltyRates
namespace royaltyRates
const double CHOICEONEROYALTIES ;
const double CHOICETWOROYALTYRATE ;
const double CHOICETHREEROYALTYRATEUNDER;
const double CHOICETHREEROYALTYRATEOVER;
const int CHOICETHREETHRESHOLD ;
int main
Declare variables
double bookCost;
int soldCopies;
double optiontworoyalties;
double optionthreeroyalties;
string bestoption;
Read cost of book
cout "Enter the net price of each copy of the novel: ;
cin bookCost;
Read number of copies sold
cout "Enter the estimated number of copies that will be sold: ;
cin soldCopies;
Calculate the option royalties amount
optiontworoyalties bookCost royaltyRates::CHOICETWOROYALTYRATE soldCopies;
Calculate the option royalties amount
if soldCopies royaltyRates::CHOICETHREETHRESHOLD
optionthreeroyalties bookCost soldCopies royaltyRates::CHOICETHREEROYALTYRATEUNDER;
else
optionthreeroyalties bookCost royaltyRates::CHOICETHREETHRESHOLD royaltyRates::CHOICETHREEROYALTYRATEUNDER
bookCost soldCopies royaltyRates::CHOICETHREETHRESHOLD royaltyRates::CHOICETHREEROYALTYRATEOVER;
Determine the best option
if royaltyRates::CHOICEONEROYALTIES optiontworoyalties && royaltyRates::CHOICEONEROYALTIES optionthreeroyalties
bestoption "Option ;
else if optiontworoyalties royaltyRates::CHOICEONEROYALTIES && optiontworoyalties optionthreeroyalties
bestoption "Option ;
else
bestoption "Option ;
Print the three royalties
cout fixed setprecision;
cout Royalty option: royaltyRates::CHOICEONEROYALTIES ;
cout Royalty option: optiontworoyalties ;
cout Royalty option: optionthreeroyalties endl;
Print the best option
cout "The best option is bestoption endl;
return ;
and these are the objectives within task
Status: PASSED!
Check:
Test: Successful Output
Reason: None
Timestamp: ::
Status: FAILED!
Check:
Test: Successful Output II
Reason: Unable to find Royalty option: 'Royalty option: 'Royalty option: 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 option: 'Royalty option: 'Royalty option:
The best option is Option
Error : AssertionError Unable to find Royalty option: in the program's output.
Timestamp: ::
Status: PASSED!
Check:
Test: Check for constant declaration innamespace
Reason: namespace royaltyRates was found in the program.None
as you can see i have two out of three but cant figure out why task keeps failing and when i put it in visual studios i have no errors. very confused and need help please!
this is the full set of information including the error i keep getting, i have no idea what extra details i can offer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started