Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- using namespace std;
- //shift letter
- int start[12] = {6, 2, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
- int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
- //i lack creativity in names w/e
- string months[12] = {"january", "february", "march", "april", "may", "june", "july", "august", "septmber", "october", "november", "december"};
- //i lack creativity w/e
- string lower (string word) {
- char letter;
- int num;
- string newword;
- int foo = word.length();
- int i = 0;
- for (i; i < foo; i++) {
- letter = word[i];
- num = letter;
- if(num > 64 && num < 91) {
- int change = + 32;
- int newnum = num + change;
- newword += newnum;
- }
- else {
- newword += letter;
- }
- }
- //cout << "You gave " << word << " The new word is \n" << newword << endl;
- //above was used for testing
- return newword;
- }
- void createMonth(string real_month, string month, int num) {
- //incase the program has contunited use
- int x = 0;
- int y = 0;
- string fileName;
- fileName = month + ".txt";
- ofstream data;
- data.open (fileName.c_str());
- data << " " << real_month << endl;
- data << " S M T W T F S" << endl;
- int sev = 0;
- for (int x = 1; x <= days[num]; x++) {
- for (y; y < start[num]; y++) {
- data << " ";
- sev++;
- }
- if (sev > 6) {
- data << endl;
- sev = 0;
- }
- data << setw(4) << x;
- sev++;
- }
- data.close();
- }
- int main() {
- string month = "start";
- while (lower(month) !="done") {
- cout << "what month do you want?\n";
- cin >> month;
- int i;
- i = 0;
- string real_month = lower(month);
- for(i; i < 12; i++) {
- if (months[i] == real_month) {
- //it will be a real month
- createMonth(real_month, month, i);
- cout << "your calender has been created in the current directory and is called..\n" << month << ".txt" << endl;
- }
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment