Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. // Pass6.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <string>
  6. #include <iostream>
  7. #include <iomanip>
  8.  
  9. using namespace std;
  10.  
  11.  
  12. int main()
  13. {
  14.     string cont = "y";
  15.     while (cont == "y" || cont == "x"){
  16.         int year = 0;
  17.         string month = "";
  18.         int daysPerMonth = 0;
  19.         int dayStart = 0;
  20.    
  21.         cout << "Welcome to Kevin Douglas's calendar program!" << endl;
  22.    
  23.         cout << "Please enter the year:";
  24.         cin >> year;
  25.         cout << endl;
  26.    
  27.         cout << "Please enter the name of the month:";
  28.         cin >> month;
  29.         cout << endl;
  30.    
  31.         cout << "Please enter the number of days in the month:";
  32.         cin >> daysPerMonth;
  33.         cout << endl;
  34.    
  35.         dayStart = -1;
  36.         while (dayStart < 0 || dayStart > 6){
  37.             cout << "Please enter the day the month starts: " << endl;
  38.             cout << "[0=Sun | 1=Mon | 2=Tue | 3=Wed | 4=Thu | 5=Fri | 6=Sat]";
  39.             cin >> dayStart;
  40.             cout << endl;
  41.         }
  42.    
  43.         cout << setw(2);
  44.         cout << month << " " << year << endl;
  45.    
  46.         cout << setw(2) << "Su ";
  47.         cout << setw(2) << "Mo ";
  48.         cout << setw(2) << "Tu ";
  49.         cout << setw(2) << "We ";
  50.         cout << setw(2) << "Th ";
  51.         cout << setw(2) << "Fr ";
  52.         cout << setw(2) << "Sa " <<endl;
  53.        
  54.         int column = 0;
  55.         int y = 0;
  56.    
  57.         for ( y = 0; y < dayStart + daysPerMonth; y++){
  58.            
  59.             if (y < dayStart){
  60.                 cout << setw(2) << "-";
  61.                 cout << " ";
  62.                 column++;
  63.             }
  64.             else{
  65.                 if (column % 7 == 0){
  66.                     cout << setw(2) << " " << endl;
  67.                 }
  68.  
  69.                 cout << setw(2) << y+1 - dayStart;
  70.                 cout << " ";
  71.                
  72.            
  73.                 column++;
  74.                
  75.             }
  76.    
  77.         }
  78.         cout << endl;
  79.         cout << "Would you like to continue?  (y/n)";
  80.         cin >> cont;
  81.         }
  82.         cout << "TERMINATED...(I'll be back...)" << endl;
  83.         system("pause");
  84.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement