Question

How can I modify my program to return the option with the highest amount ? //A...

How can I modify my program to return the option with the highest amount ?

//A new author is in the process of negotiating a contract for a new romance novel.

//The publisher is offering three options.

//1. The author is paid $5,000 upon delivery of the final manuscript and $20,000 when the novel is published.

//2. In the second option, the author is paid 12.5% of the net price of the novel for each copy of the novel sold.

//3.In the third option, the author is paid 10% of the net price for the first 4000 copies sold, and 14% of the net price for the copies sold over 4000.

//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 royalties rates and fixed royalties.)

#include<iostream>

#include<iomanip>

using namespace std;

class author {

public:

void getData();

void printData();

int option_1();

int option_2();

int option_3();

private:

bool isFound = false;

double netprice;

int copies;

int option;

};

int main () {

author Twain;

  

Twain.getData();

Twain.printData();

return 0;

}

void author::getData() {

cout << "Enter the net price of each copy of the novel: ";

cin >> netprice;

cin.ignore(100, '\n');

cout << "Enter the number of copies that will be sold: ";

cin >> copies;

cout << endl; }

int author::option_1() {

return 5000 + 20000; }

int author::option_2() {

return (netprice + (netprice*.125)) * copies ; }

int author::option_3() {

if (copies < 4000)

return (netprice + (netprice*.10)) * copies;

else

return ((netprice + (netprice*.10)) * copies) + ((netprice + (netprice*.14)) * copies); }

void author::printData() {

cout << left << setw(20) << "Net Price: " << netprice << endl;

cout << left << setw(20) << "Copies: " << copies << endl;

cout << left << setw(30) << "\nAmount for each option: " << endl;

cout << left << setw(20) << "Option 1: " << option_1() << endl;

cout << left << setw(20) << "Option 2: " << option_2() << endl;

cout << left << setw(20) << "Option 3: " << option_3() << endl; }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

#include<iostream>

#include<iomanip>

using namespace std;

class author {

public:

void getData();

void printData();

int option_1();

int option_2();

int option_3();

int highest();

private:

bool isFound = false;

double netprice;

int copies;

int option;

};

int main () {

author Twain;

Twain.getData();

Twain.printData();

return 0;

}

void author::getData() {

cout << "Enter the net price of each copy of the novel: ";

cin >> netprice;

cin.ignore(100, '\n');

cout << "Enter the number of copies that will be sold: ";

cin >> copies;

cout << endl;

}

int author::option_1() {

return 5000 + 20000;

}

int author::option_2() {

return (netprice + (netprice*.125)) * copies ;

}

int author::option_3() {

if (copies < 4000)

return (netprice + (netprice*.10)) * copies;

else

return ((netprice + (netprice*.10)) * copies) + ((netprice + (netprice*.14)) * copies);

}

int author::highest(){

int n1 = option_1(), n2 = option_2(), n3 = option_3();

if (n1>=n2)

{

if(n1>=n3)

return n1;

else

return n3;

}

else

{

if(n2>=n3)

return n2;

else

return n3;

}

}

void author::printData() {

cout << left << setw(20) << "Net Price: " << netprice << endl;

cout << left << setw(20) << "Copies: " << copies << endl;

cout << left << setw(30) << "\nAmount for each option: " << endl;

cout << left << setw(20) << "Option 1: " << option_1() << endl;

cout << left << setw(20) << "Option 2: " << option_2() << endl;

cout << left << setw(20) << "Option 3: " << option_3() << endl;

cout<<" Highest: "<<highest()<<endl;

}

Add a comment
Know the answer?
Add Answer to:
How can I modify my program to return the option with the highest amount ? //A...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C ++ program i have 75% correct. im missing the part where you mention which option...

    C ++ program i have 75% correct. im missing the part where you mention which option 3 is best. also the final calculation for options 1 & 2 #include <iostream> #include <iomanip> using namespace std; int main() { double option1, option2, option3, copiesSold, priceperCopy, tenPercent, fourteenPercent; double finalManu, published;    cout << fixed << showpoint << setprecision(2); cout<<"Enter price of each copy: "; cin>>priceperCopy; cout<<"Estimated number of copies sold: "; cin>>copiesSold; finalManu = 5000, published = 20000;    if (copiesSold...

  • A new author is in the process of negotiating a contract for a new romance novel....

    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 $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...

  • How can I make this compatible with older C++ compilers that DO NOT make use of...

    How can I make this compatible with older C++ compilers that DO NOT make use of stoi and to_string? //Booking system #include <iostream> #include <iomanip> #include <string> using namespace std; string welcome(); void print_seats(string flight[]); void populate_seats(); bool validate_flight(string a); bool validate_seat(string a, int b); bool validate_book(string a); void print_ticket(string passenger[], int i); string flights [5][52]; string passengers [4][250]; int main(){     string seat, flight, book = "y";     int int_flight, p = 0, j = 0;     int seat_number,...

  • fully comments for my program, thank you will thumb up #include <iostream> #include <fstream> #include <string>...

    fully comments for my program, thank you will thumb up #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; struct book { int ISBN; string Author; string Title; string publisher; int Quantity; double price; }; void choice1(book books[], int& size, int MAX_SIZE) { ifstream inFile; inFile.open("inventory.txt"); if (inFile.fail()) cout <<"file could not open"<<endl; string str;    while(inFile && size < MAX_SIZE) { getline(inFile, str); books[size].ISBN = atoi(str.c_str()); getline(inFile, books[size].Title);    getline(inFile, books[size].Author); getline(inFile, books[size].publisher);          getline(inFile,...

  • Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency...

    Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency in sorting the employee’s net pay. //I need to use an EXSEL sort in order to combine the selection and Exchange sorts for my program. I currently have a selection sort in there. Please help me with replacing this with the EXSEL sort. //My input files: //My current code with the sel sort. Please help me replace this with an EXSEL sort. #include <fstream>...

  • Can I get help with adding the following to this code please? 1. When buying multiple...

    Can I get help with adding the following to this code please? 1. When buying multiple tickets, if one of the seats selected is already taken, give a message like "Sorry, one or more of the seats selected is already taken." and prompt the user to select the seats all over. (Or if possible to make it suggest a location where the seats are together that the user can select instead) 2. Print the total cost after all of the...

  • 1. in this programe i want add some products to be shown after choosing choise (...

    1. in this programe i want add some products to be shown after choosing choise ( show all products ) before i add any products. let say 10 products have added to the program then when the user choose (show all products ) all the 10 products appear and the user going to choose one and that one must has its own name, price,and quantity after that the quantity will be reduce. 2. allow the user to buy products. ===========================================================...

  • my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip>...

    my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip> #include<string> #include "bookdata.h" #include "bookinfo.h" #include "invmenu.h" #include "reports.h" #include "cashier.h" using namespace std; const int ARRAYNUM = 20; BookData bookdata[ARRAYNUM]; int main () { bool userChoice = false; while(userChoice == false) { int userInput = 0; bool trueFalse = false; cout << "\n" << setw(45) << "Serendipity Booksellers\n" << setw(39) << "Main Menu\n\n" << "1.Cashier Module\n" << "2.Inventory Database Module\n" << "3.Report Module\n"...

  • The following is a sample inventory in C++, i want to ask the user to input a item number for removing from inventory. //CPP #include <iostream> #include <fstream> #include <cstdlib>...

    The following is a sample inventory in C++, i want to ask the user to input a item number for removing from inventory. //CPP #include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> #define MAX 1000 using namespace std; //Function to Add a new inventory item to the data into the array in memory void addItem(string desc[],string idNum[], float prices[], int qty[],int &num) { cout<<"Enter the names:"; cin>>desc[num]; cout<<"Enter the item number:"; cin>>idNum[num]; cout<<"Enter the price of item:"; cin>>prices[num]; cout<<"Enter the...

  • I need this done in C++ Can someone help me get my code from crashing. The...

    I need this done in C++ Can someone help me get my code from crashing. The code compiles but it can be easily crashed with user input. The rubric and code below Instructions: Write a program that scores the following data about a soccer player in a structure:            Player’s Name            Player’s Number            Points Scored by Player      The program should keep an array of 12 of these structures. Each element is for a different player on a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT