Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pass6.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <string>
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- string cont = "y";
- while (cont == "y" || cont == "x"){
- int year = 0;
- string month = "";
- int daysPerMonth = 0;
- int dayStart = 0;
- cout << "Welcome to Kevin Douglas's calendar program!" << endl;
- cout << "Please enter the year:";
- cin >> year;
- cout << endl;
- cout << "Please enter the name of the month:";
- cin >> month;
- cout << endl;
- cout << "Please enter the number of days in the month:";
- cin >> daysPerMonth;
- cout << endl;
- dayStart = -1;
- while (dayStart < 0 || dayStart > 6){
- cout << "Please enter the day the month starts: " << endl;
- cout << "[0=Sun | 1=Mon | 2=Tue | 3=Wed | 4=Thu | 5=Fri | 6=Sat]";
- cin >> dayStart;
- cout << endl;
- }
- cout << setw(2);
- cout << month << " " << year << endl;
- cout << setw(2) << "Su ";
- cout << setw(2) << "Mo ";
- cout << setw(2) << "Tu ";
- cout << setw(2) << "We ";
- cout << setw(2) << "Th ";
- cout << setw(2) << "Fr ";
- cout << setw(2) << "Sa " <<endl;
- int column = 0;
- int y = 0;
- for ( y = 0; y < dayStart + daysPerMonth; y++){
- if (y < dayStart){
- cout << setw(2) << "-";
- cout << " ";
- column++;
- }
- else{
- if (column % 7 == 0){
- cout << setw(2) << " " << endl;
- }
- cout << setw(2) << y+1 - dayStart;
- cout << " ";
- column++;
- }
- }
- cout << endl;
- cout << "Would you like to continue? (y/n)";
- cin >> cont;
- }
- cout << "TERMINATED...(I'll be back...)" << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement