Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. float convertAmountOwed(string amountOwed);
  6. float convertAmountPaid(string amountPaid);
  7. bool checkifShort(float amountOwed, float amountPaid);
  8. void performCalculation(float amountOwed, float amountPaid);
  9.  
  10. int main()
  11. {
  12. string amountOwed;
  13. string amountPaid;
  14.  
  15. cout << "Total Amount Owed" << '\n' << "$";
  16. cin >> amountOwed;
  17.  
  18. cout << "Amount Paid" << '\n' << "$";
  19. cin >> amountPaid;
  20.  
  21. float amountO = convertAmountOwed(amountOwed);
  22. float amountP = convertAmountPaid(amountPaid);
  23. if (checkifShort(amountP, amountO)) {
  24. cout << "You still owe: $" << amountO - amountP << '\n';
  25. }
  26. else {
  27. cout << "---------------------------" << '\n';
  28. performCalculation(amountO, amountP);
  29. cout << '\n' << "---------------------------" << '\n';
  30. }
  31. system("pause");
  32. return 0;
  33. }
  34.  
  35.  
  36. float convertAmountOwed(string amountOwed) {
  37.  
  38. float amountO = std::stof(amountOwed);
  39.  
  40. return amountO;
  41.  
  42. }
  43. float convertAmountPaid(string amountPaid) {
  44.  
  45. float amountP = std::stof(amountPaid);
  46.  
  47. return amountP;
  48. }
  49. bool checkifShort(float amountPaid, float amountOwed) {
  50.  
  51. return (amountPaid < amountOwed);
  52. }
  53.  
  54. void performCalculation(float amountOwed, float amountPaid) {
  55. float amountChange = amountPaid - amountOwed;
  56. cout << amountChange;
  57. while (amountChange != 0) {
  58. if (amountChange - 100 !=0) {
  59.  
  60.  
  61. }
  62.  
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement