Guest User

Untitled

a guest
Jan 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <iomanip>
  5. using namespace std;
  6. //shift letter
  7.  
  8. int start[12] = {6, 2, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
  9. int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  10. //i lack creativity in names w/e
  11. string months[12] = {"january", "february", "march", "april", "may", "june", "july", "august", "septmber", "october", "november", "december"};
  12. //i lack creativity w/e
  13.  
  14. string lower (string word) {
  15.     char letter;
  16.     int num;
  17.     string newword;
  18.     int foo = word.length();
  19.     int i = 0;
  20.     for (i; i < foo; i++) {
  21.         letter = word[i];
  22.         num = letter;
  23.         if(num > 64 && num < 91) {
  24.             int change = + 32;
  25.             int newnum = num + change;
  26.             newword += newnum;
  27.         }
  28.         else {
  29.             newword += letter;
  30.         }
  31.     }
  32.     //cout << "You gave " << word << " The new word is \n"  << newword << endl;
  33.     //above was used for testing
  34.     return newword;
  35. }
  36.  
  37. void createMonth(string real_month, string month, int num) {
  38.     //incase the program has contunited use
  39.     int x = 0;
  40.     int y = 0;
  41.     string fileName;
  42.     fileName = month + ".txt";
  43.     ofstream data;
  44.     data.open (fileName.c_str());
  45.     data << "    " << real_month << endl;
  46.     data << "   S   M   T   W   T   F   S"  << endl;
  47.     int sev = 0;
  48.     for (int x = 1; x <= days[num]; x++) {
  49.         for (y; y < start[num]; y++) {
  50.             data << "    ";
  51.             sev++;
  52.         }
  53.         if (sev > 6) {
  54.             data << endl;
  55.             sev = 0;
  56.         }
  57.         data << setw(4) << x;
  58.         sev++;
  59.     }
  60.     data.close();
  61. }
  62.    
  63.  
  64. int main() {
  65.     string month = "start";
  66.     while (lower(month) !="done") {
  67.         cout << "what month do you want?\n";
  68.         cin >> month;
  69.         int i;
  70.         i = 0;
  71.         string real_month = lower(month);
  72.         for(i; i < 12; i++) {
  73.             if (months[i] == real_month) {
  74.                 //it will be a real month
  75.                 createMonth(real_month, month, i);
  76.                 cout << "your calender has been created in the current directory and is called..\n" << month << ".txt" << endl;
  77.             }
  78.         }
  79.     }
  80.     return 0;
  81. }
Add Comment
Please, Sign In to add comment