Advertisement
wheelsmanx

CPS171 Machine Problem 3

Oct 17th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <string>
  7. using namespace std;
  8.  
  9. float numberofunits = 50;
  10. float numberofunitsfree = 0;
  11. float normalrent = 600;
  12. float increase = 40;
  13. float maint = 27;
  14. // I calculated this number out - assuming that all units are full - to give the while loop a jumping off point
  15. float profit = 28650;
  16. float prevprofit = 28650;
  17.  
  18.  
  19. int main()
  20. {
  21. if (profit == 0) {
  22. profit = (numberofunits * normalrent) - (numberofunits * maint);
  23. prevprofit = profit;
  24. }
  25.  
  26.  
  27. while (prevprofit <= profit) {
  28. prevprofit = profit;
  29. cout << "Number of Units Full: " << numberofunits << endl;
  30. cout << "Rent at current number of units: " << normalrent << endl;
  31. cout << "Profit: " << profit << endl;
  32. normalrent = (numberofunitsfree * 40);
  33. normalrent = normalrent + 600;
  34. profit = numberofunits * normalrent;
  35. profit = profit - (maint * numberofunits);
  36. numberofunits = numberofunits - 1;
  37. numberofunitsfree = numberofunitsfree + 1;
  38.  
  39.  
  40.  
  41. }
  42. cout << endl;
  43. cout << endl;
  44. cout << "Most Efficient Business Model is: " << prevprofit << endl;
  45. cout << "Number of Units Full: " << numberofunits + 1 << endl;
  46. cout << "Rent at current number of units: " << normalrent - 40 << endl;
  47. cout << "Profit: " << prevprofit << endl;
  48. cout << endl;
  49.  
  50.  
  51.  
  52.  
  53. system("pause");
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement