Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have passed two of the three trials pls help pass the last one ASAP - Status: PASSED! Check: 1 Test: Successful Output Reason: None

I have passed two of the three trials pls help pass the last one ASAP- Status: PASSED!
Check: 1
Test: Successful Output
Reason: None
Timestamp: 2024-07-0518:07:54.902408
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.
Please enter the net price per copy: Please also enter the estimated amount of copies that will sell: Royalty option1: 25000.00
Royalty option2: 771604931.25
Royalty option3: 617283945.00
The best option for you is Option 2.
.
Error : AssertionError - Unable to find Royalty option3: 864189523.00 in the program's output.
Timestamp: 2024-07-0518:07:54.904625
Status: PASSED!
Check: 3
Test: Check for constant declaration in`namespace`
Reason: namespace royaltyRates +` was found in the program.None
Timestamp: 2024-07-0518:07:54.905018 and here is my code - #include
#include
using namespace std;
namespace royaltyRates {
const double OPTION1_FIXED_ROYALTY =25000.0;
const double OPTION2_ROYALTY_RATE =0.125;
const double OPTION3_FIRST_4000_RATE =0.10;
const double OPTION3_OVER_4000_RATE =0.14;
void calculateRoyalties(){
double netPricePerCopy;
int estimatedCopiesSold;
cout << fixed << setprecision(2);
// Input net price per copy and estimated copies sold
cout << "Please enter the net price per copy: ";
cin >> netPricePerCopy;
if (netPricePerCopy <0){
cout << "Invalid input for net price per copy. It must be non-negative.
";
return;
}
cout << "Please also enter the estimated amount of copies that will sell: ";
cin >> estimatedCopiesSold;
if (estimatedCopiesSold <0){
cout << "Invalid input for estimated copies sold. It must be non-negative.
";
return;
}
double option1Royalty = OPTION1_FIXED_ROYALTY;
double option2Royalty = netPricePerCopy * estimatedCopiesSold * OPTION2_ROYALTY_RATE;
double option3Royalty;
if (estimatedCopiesSold <=4000){
option3Royalty = netPricePerCopy * estimatedCopiesSold * OPTION3_FIRST_4000_RATE;
} else {
option3Royalty =(4000* netPricePerCopy * OPTION3_FIRST_4000_RATE)+
((estimatedCopiesSold -4000)* netPricePerCopy * OPTION3_OVER_4000_RATE);
}
// Output royalties for each option
cout << "Royalty option1: "<< option1Royalty << endl;
cout << "Royalty option2: "<< option2Royalty << endl;
cout << "Royalty option3: "<< option3Royalty << endl;
// Determine the best option
if (option1Royalty > option2Royalty && option1Royalty > option3Royalty){
cout << "The best option for you is Option 1.
";
} else if (option2Royalty > option1Royalty && option2Royalty > option3Royalty){
cout << "The best option for you is Option 2.
";
} else {
cout << "The best option for you is Option 3.
";
}
}
}
using namespace royaltyRates;
int main(){
calculateRoyalties();
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions