fork download
  1. //OrinTill Qimid CS1A Chapter 4, P. 294, 10
  2. //
  3. /**************************************************************
  4.  * Compute buget.
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will help a person keepo track of their monthly spending.
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * budget :the montly budget
  11.  * spend :the monthly expense
  12.  * OUTPUT
  13.  * tspend :the total spending
  14.  * diff :the difference in buget and spending.
  15.  **************************************************************/
  16. #include <iostream>
  17. #include <iomanip>
  18. #include <cmath>
  19. using namespace std;
  20.  
  21. int main()
  22. {
  23. float budget=0,
  24. spend=0,
  25. tspend=0,
  26. diff;
  27. char choice;
  28. cout<<"what is your monthly buget?"<<endl;
  29. cin>>budget;
  30.  
  31. do
  32. {
  33. cout<<"enter an expense"<<endl;
  34. cin >> spend;
  35. tspend+=spend;
  36. cout<<"Do you have another expense to enter? (Y/N)"<<endl;
  37. cin>> choice;
  38. } while (choice=='Y' || choice=='y');
  39. diff = budget-spend;
  40. cout<<"Your total expense is: $"<<tspend<<endl;
  41. if (diff>0)
  42. {
  43. cout<<"You are under the buget by $"<< diff <<endl;
  44.  
  45. }else if (diff<0)
  46. {
  47. cout<<"You are over the budget by $"<<diff<<endl;
  48. }
  49. else{
  50. cout<<"You are exactly on budge!!"<<endl;
  51. }
  52. return 0;
  53. }
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
Standard output is empty