So I started off with a simple project below. Basically I set it up so that when it was the weekends it would say "Its The Weekends!". However I'm a beginer at programming, and so I had to make it so I manually had to tell the program what day it way. I was hoping I could make it so that the program automatically grabs the time from the OS, and calculated if its the weekends or Weekdays.
// DaysOfTheWeek.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include < iostream >
#include < cmath >
usingnamespace std;
int main ()
{
float dwi; // Input data for day of week year began
float dyi; // Input data for the day of the year
double dayOfYear; // Output data for day of year
bool numbersAreOK; // True if data is within the range of 1-366
// Prompt for what day of the week the year begins on
cout << "To represent what day the year began on, please enter a whole number from 0-6."" ""0 representing Sunday, 6 representing Saturday. " << endl;
cin >> dwi;
// Prompt for the day of the year
cout << " Please enter a whole number from 1-366 to represent the day of the year you wish to display." << endl;
cin >> dyi;
// Test Data
if ( dwi < 0 || dwi > 6)
numbersAreOK = false;
cout << "Invalid data, please try again." << endl;
if ( dyi < 1 || dyi > 366)
numbersAreOK = false;
cout << "Invalid Data, Please try again." << endl;
if ( numbersAreOK = true)
{
// Calculate day of year
double dayOfYear = (dwi + dyi-1)%7;
// Print Day of Year
if (dayOfYear == 0)
cout << "Sunday" << endl;
elseif (dayOfYear == 1)
cout << "Monday" << endl;
elseif (dayOfYear == 2)
cout << "Tuesday" << endl;
elseif (dayOfYear == 3)
cout << "Wednesday" << endl;
elseif (dayOfYear == 4)
cout << "Thursday" << endl;
elseif (dayOfYear == 5)
cout << "Friday" << endl;
elseif (dayOfYear == 6)
cout << "Saturday" << endl;
}
cin.get();
cin.get();
return 0;
}