Advertisement
desislava_topuzakova

05. Travelling

Feb 12th, 2023
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. //while
  7. //повтаряме: въвеждат държави
  8. //стоп: destination == "End"
  9. //продължаваме: destination != "End"
  10.  
  11. string destination; //държава или "End"
  12. cin >> destination;
  13.  
  14. while (destination != "End")
  15. {
  16. //държава за посещение -> destination
  17. double needBudget; //нужна сума за посещението
  18. cin >> needBudget;
  19.  
  20. //спестяване
  21. double savedSum = 0; //общо спестени пари
  22. //повтарям: въвеждам суми, които спестявам
  23. //стоп: savedSum >= needBudget
  24. //продължавам: savedSum < needBudget
  25. while (savedSum < needBudget)
  26. {
  27. double money; //колко пари е спестила за един ден
  28. cin >> money;
  29.  
  30. savedSum += money;
  31. }
  32. //savedSum >= needBudget -> отивам на дестинацията
  33. cout << "Going to " << destination << "!" << endl;
  34.  
  35.  
  36. cin >> destination;
  37. }
  38.  
  39.  
  40.  
  41.  
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement