answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
8090
2 months ago
14

Redo Programming Exercise 16 of Chapter 4 so that all the named constants are defined in a namespace royaltyRates. PLEASE DONT F

ORGET THIS PART- it makes me confused.Instructions for Programming Exercise 16 of Chapter 4 have been posted below for your convenience.Exercise 16A 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.)

Computers and Technology
1 answer:
maria [1K]2 months ago
5 0

Response:

The following code is provided along with the corresponding output in the diagram:

Description:

//Use this header file for visual studio.

#include "stdafx.h"

//Include requisite header files.

#include<iostream>

//Adhere to standard naming conventions.

using namespace std;

//Set up a namespace for royalty rates.

namespace royaltyRates

{

    //Declare and set the necessary constants.

    const double PAY_ON_DELIVERY_OF_NOVAL = 5000;

    const double PAY_ON_PUBLISH_OF_NOVAL = 20000;

    const double PER_ON_NET_PRICE_SECOND_OPTION =

    0.125;

    const double PER_ON_NET_PRICE_FIRST_4000 = 0.1;

    const double PER_ON_NET_PRICE_OVER_4000 = 0.14;

};

//Begin the execution of the main() function.

int main()

{

    //Declare and initialize necessary variables.

    //These will be utilized to compute

    //the royalties for each option.

    float net_price;

    int num_copies;

    float royaltyUnderOption1, royaltyUnderOption2,

    royaltyUnderOption3;

    royaltyUnderOption1 = royaltyUnderOption2

    = royaltyUnderOption3 = 0;

    //Ask the user for the net price of each

    //novel copy.

    cout << "Please enter the net price for each ";

    cout << "copy of the novel: ";

    cin >> net_price;

    //Request the user to provide the estimated quantity

    //of copies likely to be sold.

    cout << "Please enter the estimated number ";

    cout << "of copies to be sold: ";

    cin >> num_copies;

    //Output the necessary details and the royalty

    //calculated for the first option.

    cout << "\n*** Option 1: ****" << endl;

    cout << "Net price of each novel: $" << net_price;

    cout << endl;

    cout << "Estimated number of copies to be sold ";

    cout << "is: " << num_copies << endl;

    cout << "$";

    cout << royaltyRates::PAY_ON_DELIVERY_OF_NOVAL;

    cout << " is paid to the author for delivering ";

    cout << "the completed manuscript and $";

    cout << royaltyRates::PAY_ON_PUBLISH_OF_NOVAL;

    cout << " is paid for the publication of ";

    cout << "the novel." << endl;

    royaltyUnderOption1 =

    royaltyRates::PAY_ON_DELIVERY_OF_NOVAL +

    royaltyRates::PAY_ON_PUBLISH_OF_NOVAL;

    cout << "Total amount of royalty under option 1 ";

    cout << "is $" << royaltyUnderOption1 << endl;

    //Output the necessary details and the royalty

    //calculated for option 2.

    cout << "\n*** Option 2: ****" << endl;

    cout << "Net price of each novel: $";

    cout << net_price << endl;

    cout << "Estimated number of copies to be sold ";

    cout << "is: " << num_copies << endl;

    royaltyUnderOption2 =

   (royaltyRates::PER_ON_NET_PRICE_SECOND_OPTION *

    net_price)* num_copies;

    cout << "Total amount of royalty under option 2 ";

    cout << "is $" << royaltyUnderOption2 << endl;

    //Output the necessary details and royalty

    //calculated for option 3.

    cout << "\n*** Option 3: ****" << endl;

    cout << "Net price of each novel: $" << net_price;

    cout << endl;

    cout << "Estimated number of copies to be sold ";

    cout << "is: " << num_copies << endl;

    //If copies sold exceed 4000.

    if (num_copies > 4000)

    {

         //The total royalty is 10% for net

         //price of the first 4000 copies and 14% for net

         //price for those sold beyond 4000.

         royaltyUnderOption3 =

         (royaltyRates::PER_ON_NET_PRICE_FIRST_4000 *

         net_price) * 4000 +

         (royaltyRates::PER_ON_NET_PRICE_OVER_4000 *

         net_price) * (num_copies - 4000);

    }

    //Otherwise,

    else

    {

         //The royalty will amount to 10% of the net

         //price of the first 4000 copies.

         royaltyUnderOption3 =

         (royaltyRates::PER_ON_NET_PRICE_FIRST_4000 *

         net_price) * num_copies;

    }

    cout << "Total amount of royalty under option 3 ";

    cout << "is $" << royaltyUnderOption3 << endl;

    //If royalty from option 1 surpasses

    //that from options 2 and 3, option 1 is

    //the optimal choice.

    if (royaltyUnderOption1 > royaltyUnderOption2 &&

    royaltyUnderOption1 > royaltyUnderOption3)

    {

         cout << "\nOption 1 is the best option that ";

         cout << "the author can select." << endl;

    }

    //If the royalty under option 2 exceeds

    //royalties from options 1 and 3, option 2 is

    //the best choice.

    else if (royaltyUnderOption2 > royaltyUnderOption1

    && royaltyUnderOption2 > royaltyUnderOption3)

    {

         cout << "\nOption 2 is the best option that ";

         cout << "the author can select." << endl;

    }

    //If the royalty from option 3 is superior to

    //the royalties from options 1 and 2, then option 3 is

    //the ideal choice.

    else

    {

         cout << "\nOption 3 is the best option that ";

         cout << "the author can select." << endl;

    }

    //Use this command when utilizing visual studio.

    system("pause");

    return 0;

}

You might be interested in
Which decimal value (base 10) is equal to the binary number 1012?
Natasha_Volkova [1026]

Answer:

The decimal representation of 101₂² from base 2 equals 25 in base 10.

Explanation:

To derive the decimal equivalent of 101₂²;

101₂ × 101₂ results in 101₂ + 0₂ + 10100₂.

In this expression, we observe that the '2' in the hundred's place must be converted to '0' while carrying over '1' to the thousand's position, leading to;

101₂ + 0₂ + 10100₂ = 11001₂.

This shows that;

101₂² =  11001₂.

Next, we convert the outcome of squaring the base 2 number, 11001₂, into base 10 through the following method;

Converting 11001₂ to base 10 results in;

1 × 2⁴ + 1 × 2³ + 0 × 2² + 0 × 2¹ + 1 × 2⁰.

The calculation yields;

16 + 8 + 0 + 0 + 1 = 25₁₀.

7 0
2 months ago
The data in a data warehouse have which of the following characteristics?
maria [1035]
Option (d) is the correct choice. A data warehouse serves as a storage system that contains gathered information and data for informed decision-making via analysis. The information in a data warehouse is organized by subject and includes historical data along with sources to provide clarity. The other options are incorrect as they suggest that data is encoded differently, retrieved for limited times, updated in real-time, or structured hierarchically.
6 0
1 month ago
Read two numbers from user input. Then, print the sum of those numbers. Hint -- Copy/paste the following code, then just type co
maria [1035]

Answer:

num1 = int(input("Input the first number "))

num2 = int(input("Input the second number "))

print(num1 + num2)

Explanation:

This code is implemented in Python programming language.

It utilizes the input function to ask the user for the first and second number.

The values are stored in the variables num1 and num2 in that order.

The print function then calculates and displays the sum of num1 and num2.

6 0
3 months ago
Read 2 more answers
Which of the following is an absolute cell reference
Amiraneli [1052]
The term for the contents of the cell is an absolute cell reference. Excel allows each cell to contain numbers, strings, or formulas. Users can enter values into a cell and apply built-in formulas to perform calculations and obtain results in the target cell. When users attempt to copy and paste data into another cell, they can use the paste special option to select values, meaning that only the data is copied, excluding the formula; this is known as the absolute reference of the cell. With paste special, users can also replicate images or Unicode.
6 0
2 months ago
Other questions:
  • In the Scrum board, prioritizing the issue backlog is done in the ———- mode.
    7·1 answer
  • Which of these is an example of the integrity principle that can ensure your data is accurate and untampered with?
    10·2 answers
  • Why computer is known as versatile and diligent device ?explain​
    14·1 answer
  • What are the 2 things you are not sure about evaluating functions​
    7·2 answers
  • Allison wants to use equations to simplify the process of explaining something to the Sales team, but the default eq
    8·2 answers
  • The ____________ protocol enables two users to establish a secret key using a public-key scheme based on discrete logarithms
    10·1 answer
  • Which correctly lists the two elements that make up the empty space in the universe? ice and debris debris and dark matter dark
    7·2 answers
  • Which of the following is true of how packets are sent through the internet?
    10·2 answers
  • 2) Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you
    11·1 answer
  • You've just purchased 10 new notebook systems for your users. You are concerned that users will leave the systems on for long pe
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!