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
77julia77 [94]
2 years 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:
Komok [63]2 years ago
5 0

Answer:

Code is given below and output is attached in the diagram:

Explanation:

//Use this header file while using visual studio.

#include "stdafx.h"

//Include the required header files.

#include<iostream>

//Use the standard naming convention.

using namespace std;

//Define a namespace royaltyRates.

namespace royaltyRates

{

    //Declare and initialize required named 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;

};

//Start the execution of main() method.

int main()

{

    //Declare and initialize the required variables

    //which are going to be used to calculate

    //royalities under each option.

    float net_price;

    int num_copies;

    float royaltyUnderOption1, royaltyUnderOption2,

    royaltyUnderOption3;

    royaltyUnderOption1 = royaltyUnderOption2

    = royaltyUnderOption3 = 0;

    //Prompt the user to enter the net price of each

    //novel.

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

    cout << "copy of the novel : ";

    cin >> net_price;

    //Prompt the user to enter the estimated number

    //of copies of the novels to be sold.

    cout << "Please enter the estimated number ";

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

    cin >> num_copies;

    //Display the required details and royalty

    //calculated under option 1.

    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 author for the delivery of ";

    cout << "the final manuscript and $";

    cout << royaltyRates::PAY_ON_PUBLISH_OF_NOVAL;

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

    cout << "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;

    //Display the required details and royalty

    //calculated under 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;

    //Display the required details and royalty

    //calculated under 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 the number of copies is greater than 4000.

    if (num_copies > 4000)

    {

         //Total amount of royalty will be 10% of net

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

         //price of copies sold over 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

    {

         //Total amount of royalty will be 10% of net

         //price of 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 the royalty under option 1 is greater than

    //royalty under option 2 and 3, then option 1 is

    //best option.

    if (royaltyUnderOption1 > royaltyUnderOption2 &&

    royaltyUnderOption1 > royaltyUnderOption3)

    {

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

         cout << "author can choose." << endl;

    }

    //If the royalty under option 2 is greater than

    //royalty under option 1 and 3, then option 2 is

    //best option.

    else if (royaltyUnderOption2 > royaltyUnderOption1

    && royaltyUnderOption2 > royaltyUnderOption3)

    {

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

         cout << "author can choose." << endl;

    }

    //If the royalty under option 3 is greater than

    //royalty under option 1 and 2, then option 3 is

    //best option.

    else

    {

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

         cout << "author can choose." << endl;

    }

    //Use this command while using visual studio.

    system("pause");

    return 0;

}

You might be interested in
Which statement accurately describes the clutter feature in outlook 2016
I am Lyosha [343]

Answer:

The answer is the last option

8 0
1 year ago
Ishmael would like to capture a selected portion of his screen and then capture actions he preforms on that selected portion. Wh
kompoz [17]

Answer:

Use the Insert Screen .

Explanation:

Remember, on most computer keyboard you'll find a button named "Insert Screen' which functions as a screenshot too. Also, note that if Ishmael is using Windows operating system he should simply do the following;

1. open the window you want to screenshot

2. click the Screenshot button

But to select a part of the screen he would need to use Screen Clipping which would allow him select the part of the window that he wants. ( It screen will look opaque)

3. the pointer would change to a cross, then he should press and hold the left mouse button and drag to select the part of the screen that he wants to capture.

5 0
1 year ago
Write an application that allows a user to enter any number of student quiz scores until the user enters 99. If the score entere
maria [59]

Answer:

import java.util.Scanner;

import java.util.*;

import java.util.Collections;

class Main

{

public static void main(String[] args)  

{

     List<Integer> Scores = new ArrayList<Integer>();

     Scanner sc1=new Scanner(System.in);

     int i =0;

     int a=0;

     do

     {

       System.out.println("Enter score");

       a =sc1.nextInt();

       if (a <= 0)

       {

           System.out.println("You entered wrong score");

           continue;

       }

       else if ( a < 10 && a >0)

       {

           System.out.println("You entered wrong score");

           continue;

           

       }

       else

       {

           Scores.add(a);

       }

       i++;

     }while(a!=99);

     int max= Collections.max(Scores);

     int min=Collections.min(Scores);

     int sum=0;

     float averg =0;

     for(i=0; i<=Scores.size()-1;i++)

     {

        sum += Scores.get(i);

     }

     averg= sum/Scores.size();

     System.out.println("Maximum score" +max);

      System.out.println("Minimum score"+min);

     System.out.println("Average:"+averg);

   

}

}

Explanation:

Remember we need to use Arraylist and not array, as we do not know how many scores we are going to have. And we use Collections for this, where we have functions for finding maximum and minimum for arraylist, however, for average, we need to calculate. However, one should know that Arraylist has better options available as compare to arrays.

3 0
1 year ago
The term eof represents
rewona [7]

Answer:

EOF stands for End Of File

Google explains it well: EOF is a condition in a computer operating system where no more data can be read from a data source. The data source is usually called a file or stream.

8 0
1 year ago
Read 2 more answers
Given x and y, each associated with an int, write a fragment of code that associates the larger of these with another variable n
solmaris [256]

Answer:

The program to this question as follows:

Program:

x=int(input('Input the first number: ')) #defining variable x and input value by user

y=int(input('Input the second number: ')) #defining variable y and input value by user

if x > y: #if block to check value x>y

   max=x #define variable max that hold variable x value

   print('max number is: ', x) #print value

else: #else block

   max=y  #define variable max that holds variable y value

   print('max number is: ', y) #print value

Output:

Input the first number: 22

Input the second number: 33

max number is:  33

Explanation:

In the above code two-variable, "x and y" is defined, which holds a value, which is input by the variable. In the next step, the if block statement is used that can be described as follows:

  • In the if block, it will check x is greater than y it will define a variable, that is "max", that holds variable x value and prints its value.
  • In the else block, if the above condition is false it uses the max variable, that holds variable y value and prints its value.
8 0
2 years ago
Other questions:
  • What best describes the purpose of the Recycle Bin (Microsoft Windows) and Trash (Apple Mac) features
    13·2 answers
  • Annabeth has been using a public cloud to store and access her documents. Which drawback of a public cloud should she be aware o
    11·1 answer
  • The most direct way for Jonathan to gain on-the-job experience and earn money while attending school is to apply for:
    5·2 answers
  • Poor quality lateral communication will result in which ofthe
    13·2 answers
  • Thomas has signed a deal with a production house that allows them to use his images on their website. What is required when imag
    5·2 answers
  • Which of the following is an absolute cell reference
    10·1 answer
  • Delete Prussia from country_capital. Sample output with input: 'Spain:Madrid,Togo:Lome,Prussia: Konigsberg' Prussia deleted? Yes
    13·1 answer
  • You have implemented a network where hosts are assigned specific roles, such as for file sharing and printing. Other hosts acces
    7·1 answer
  • A packet analyzer is a program that can enable a hacker to do all of the following EXCEPT ________. Select one: A. assume your i
    6·1 answer
  • Define a method printAll() for class PetData that prints output as follows with inputs "Fluffy", 5, and 4444. Hint: Make use of
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!