Advertisement
janac

Calculate number of apps to sell to make $100,000

Jan 6th, 2022
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. // Determine how many apps to sell at a
  2. // particular price to make $100,000.
  3.  
  4. #include <iostream>
  5. #include <cmath> // ceil(), rounds up to the next integer
  6.  
  7. using namespace std;
  8.  
  9. // This function calculates how many apps to
  10. // sell, based on the price, to make $100,000
  11. // after 25% tax.
  12. int sell_this_many(float price)
  13. {
  14.     // Calculate exactly how many apps reach the goal after taxes.
  15.     // (revenue goal / portion after taxes) / price of app
  16.     float first_result = (100000 / .75) / price;
  17.  
  18.     // Cannot sell a fraction of an app, so
  19.     // round up to the next whole number.
  20.     return ceil(first_result);
  21. }
  22.  
  23.  
  24.  
  25. int main()
  26. {
  27.     float price = 0; // Chosen price of app.
  28.     int num_to_sell = 0; // How many to sell.
  29.  
  30.     cout << "What is the price of your app? ";
  31.     cin >> price; // Get price of app.
  32.  
  33.     num_to_sell = sell_this_many(price); // Calculate how many to sell.
  34.  
  35.     // Display result.
  36.     cout << "To make $100,000 after taxes, you must sell " << num_to_sell << " apps.\n";
  37.  
  38.     return 0; // End the program.
  39. }
  40.  
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement