#CODING HW

17 messages · Page 1 of 1 (latest)

rotund pawnBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

rotund pawnBOT
#

MY CODE: ```cpp
#include <iostream>

using namespace std;

namespace royaltyRates {
const double FIXED_ROYALTY = 5000.0;
const double FINAL_ROYALTY = 20000.0;
const double OPTION2_RATE = 0.125;
const double OPTION3_RATE1 = 0.10;
const double OPTION3_RATE2 = 0.14;
const int OPTION3_THRESHOLD = 4000;
} // namespace royaltyRates

int main() {
double netPrice, royalties1, royalties2, royalties3;
int numSold;
using namespace royaltyRates;

cout << "Enter the net price of each copy of the novel: $";
cin >> netPrice;
cout << "Enter the estimated number of copies that will be sold: ";
cin >> numSold;

royalties1 = FIXED_ROYALTY + FINAL_ROYALTY;
royalties2 = OPTION2_RATE * netPrice * numSold;
if (numSold > OPTION3_THRESHOLD) {
royalties3 = OPTION3_RATE1 * netPrice * OPTION3_THRESHOLD +
OPTION3_RATE2 * netPrice * (numSold - OPTION3_THRESHOLD);
} else {
royalties3 = OPTION3_RATE1 * netPrice * numSold;
}

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "Royalties under option one: $" << royalties1 << endl;
cout << "Royalties under option two: $" << royalties2 << endl;
cout << "Royalties under option three: $" << royalties3 << endl;

if (royalties1 >= royalties2 && royalties1 >= royalties3)
cout << "The best option is option one." << endl;
else if (royalties2 >= royalties1 && royalties2 >= royalties3)
cout << "The best option is option two." << endl;
else
cout << "The best option is option three." << endl;

return 0;
}

Monke
analog lintel
#

I don't see a question here. Please ask a question, not just posting the HW question and your code.

vestal lotus
#

@analog lintel

analog lintel
#

Please ask an actual question and not just post an image

#

Help us help you

vestal lotus
#

When I run check I get this Test case Incomplete

analog lintel
#

I don't need you to paste your unformatted code again

#

Have you done any kind of debugging?

vestal lotus
#

no

analog lintel
#

Please go do that then

#

Posting an entire wall of code, asking someone to digest and understand it, and then tell you what's wrong is a really big ask

vestal lotus
#

im just asking where i am doing wrong

#

im not asking to fkn do it all

#

but whatver

rotund pawnBOT
#

@vestal lotus

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.