Guest User

Untitled

a guest
Nov 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <fstream>
  3. #include <iostream>
  4. #include <string>
  5. #include <sstream>
  6. #include <ios>
  7. #include <stdio.h>
  8. #include <ctype.h>
  9. #include <string>
  10. #include <cctype>
  11.  
  12.  
  13. using namespace std;
  14.  
  15. string catalogue(int);
  16. float pricefunc(int);
  17.  
  18. int main()
  19. {
  20. string month, describe;
  21. int year, sent=1, bulan, endday, day, i = 1;
  22. float price, total = 0;
  23.  
  24. stringstream filename;
  25.  
  26.  
  27. cout << "Enter month" << endl;
  28. cin >> bulan;
  29.  
  30. switch (bulan)
  31. {
  32. case 1:
  33. {month = "January";
  34. endday = 31;}
  35. case 2:
  36. {month = "February";
  37. endday = 28;}
  38. case 3:
  39. {month = "March";
  40. endday = 31;}
  41. case 4:
  42. {month = "April";
  43. endday = 30;}
  44. case 5:
  45. {month = "May";
  46. endday = 31;}
  47. case 6:
  48. {month = "June";
  49. endday = 30;}
  50. case 7:
  51. {month = "July";
  52. endday = 31;}
  53. case 8:
  54. {month = "August";
  55. endday = 31;}
  56. case 9:
  57. {month = "September";
  58. endday = 30;}
  59. case 10:
  60. {month = "October";
  61. endday = 31;}
  62. case 11:
  63. {month = "November";
  64. endday = 30;}
  65. case 12:
  66. {month = "December";
  67. endday = 31;}
  68. }
  69.  
  70.  
  71. cout << "Enter year" << endl;
  72. cin >> year;
  73.  
  74. filename << "Expenses_" << month << "_" << year << ".txt";
  75.  
  76. ofstream myfile(filename.str(), ofstream::out | ofstream::app);
  77.  
  78. cout << "Day :" << endl;
  79. cin >> day;
  80.  
  81. myfile << "--------------------" << year << " " << month << " " << day << "--------------------" << endl;
  82.  
  83.  
  84. while (sent == 1)
  85. {
  86. cout << "0 to end, 1 to continue" << endl;
  87. cin >> sent;
  88.  
  89. describe = catalogue(sent);
  90. price = pricefunc(sent);
  91. total = total + price;
  92.  
  93. myfile << describe << "t";
  94. myfile << price << endl;
  95. }
  96.  
  97.  
  98. myfile << "######################## " << "Total expenses of the day: RM" << total << " #########################" << endl;
  99. return 0;
  100. }
  101.  
  102.  
  103. string catalogue(int senti)
  104. {
  105. while (senti == 1)
  106. {
  107. int count=1;
  108. string description[100];
  109. cout << count << "." << "Enter catalogue name" << endl;
  110. cin >> ws;
  111. getline(cin, description[count]);
  112. return description[count];
  113. count++;
  114. }
  115. }
  116.  
  117.  
  118. float pricefunc(int sentim)
  119. {
  120. while (sentim == 1)
  121. {
  122. int count = 1;
  123. float price[100];
  124. cout << "Enter price" << endl;
  125. cin >> price[count];
  126. return price[count];
  127. count++;
  128. }
  129. }
Add Comment
Please, Sign In to add comment