Advertisement
The_Code_Doge

Untitled

Jun 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. void challenge_1(){ //Candy Robots
  2. long double performance;
  3. long double endurance;
  4. long double cost;
  5. long double budget;
  6. long double candy_p = 0;
  7. long double time = 0;
  8. long double amt;
  9.  
  10. cout << "how many candies can a robot produce per hour ?" << endl;
  11. cin >> performance;
  12. cout << "how long(hours) can the robot produce this amount of candy per hour before only producing 1 candy per hour" << endl;
  13. cin >> endurance;
  14. cout << "what is the cost of one robot (per hour) ?" << endl;
  15. cin >> cost;
  16. cout << "what is your budget (how much money are you willing to spend) ?" << endl;
  17. cin >> budget;
  18.  
  19.  
  20.  
  21.  
  22. while(budget >= cost){
  23. while(endurance > 0){
  24. candy_p = candy_p + performance;
  25. time++;
  26. endurance--;
  27. budget = budget - cost;
  28.  
  29. }
  30.  
  31. if(endurance == 0){
  32. candy_p++;
  33. time++;
  34. budget = budget - cost;
  35.  
  36. }
  37. }
  38. if(budget < cost){
  39. cout << "\none robot~" << endl;
  40. cout << "candies produced: " << candy_p << endl;
  41. cout << "the amount of hours you were able to produce candy for: " << time << endl;
  42. cout << "your remaining budget is $" << budget << endl;
  43.  
  44.  
  45. int choice;
  46. cout << "would you like to calculate the budget needed for multiple robots ? 1=yes 2=no" << endl;
  47. cin >> choice;
  48. if (choice == 1){
  49. cout << "\nhow many robots would you like to test this with (using the same imput from before) ? " << endl;
  50. cin >> amt;
  51. cout << "the cost of those robots would be $" << (time * cost) * amt << endl;
  52. }
  53. else{
  54. }
  55.  
  56. }
  57.  
  58.  
  59.  
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement