Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <fstream>
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <ios>
- #include <stdio.h>
- #include <ctype.h>
- #include <string>
- #include <cctype>
- using namespace std;
- string catalogue(int);
- float pricefunc(int);
- int main()
- {
- string month, describe;
- int year, sent=1, bulan, endday, day, i = 1;
- float price, total = 0;
- stringstream filename;
- cout << "Enter month" << endl;
- cin >> bulan;
- switch (bulan)
- {
- case 1:
- {month = "January";
- endday = 31;}
- case 2:
- {month = "February";
- endday = 28;}
- case 3:
- {month = "March";
- endday = 31;}
- case 4:
- {month = "April";
- endday = 30;}
- case 5:
- {month = "May";
- endday = 31;}
- case 6:
- {month = "June";
- endday = 30;}
- case 7:
- {month = "July";
- endday = 31;}
- case 8:
- {month = "August";
- endday = 31;}
- case 9:
- {month = "September";
- endday = 30;}
- case 10:
- {month = "October";
- endday = 31;}
- case 11:
- {month = "November";
- endday = 30;}
- case 12:
- {month = "December";
- endday = 31;}
- }
- cout << "Enter year" << endl;
- cin >> year;
- filename << "Expenses_" << month << "_" << year << ".txt";
- ofstream myfile(filename.str(), ofstream::out | ofstream::app);
- cout << "Day :" << endl;
- cin >> day;
- myfile << "--------------------" << year << " " << month << " " << day << "--------------------" << endl;
- while (sent == 1)
- {
- cout << "0 to end, 1 to continue" << endl;
- cin >> sent;
- describe = catalogue(sent);
- price = pricefunc(sent);
- total = total + price;
- myfile << describe << "t";
- myfile << price << endl;
- }
- myfile << "######################## " << "Total expenses of the day: RM" << total << " #########################" << endl;
- return 0;
- }
- string catalogue(int senti)
- {
- while (senti == 1)
- {
- int count=1;
- string description[100];
- cout << count << "." << "Enter catalogue name" << endl;
- cin >> ws;
- getline(cin, description[count]);
- return description[count];
- count++;
- }
- }
- float pricefunc(int sentim)
- {
- while (sentim == 1)
- {
- int count = 1;
- float price[100];
- cout << "Enter price" << endl;
- cin >> price[count];
- return price[count];
- count++;
- }
- }
Add Comment
Please, Sign In to add comment