Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Determine how many apps to sell at a
- // particular price to make $100,000.
- #include <iostream>
- #include <cmath> // ceil(), rounds up to the next integer
- using namespace std;
- // This function calculates how many apps to
- // sell, based on the price, to make $100,000
- // after 25% tax.
- int sell_this_many(float price)
- {
- // Calculate exactly how many apps reach the goal after taxes.
- // (revenue goal / portion after taxes) / price of app
- float first_result = (100000 / .75) / price;
- // Cannot sell a fraction of an app, so
- // round up to the next whole number.
- return ceil(first_result);
- }
- int main()
- {
- float price = 0; // Chosen price of app.
- int num_to_sell = 0; // How many to sell.
- cout << "What is the price of your app? ";
- cin >> price; // Get price of app.
- num_to_sell = sell_this_many(price); // Calculate how many to sell.
- // Display result.
- cout << "To make $100,000 after taxes, you must sell " << num_to_sell << " apps.\n";
- return 0; // End the program.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement