//============================================================================
// Name : Assignment.cpp
// Author : Zachary Standridge
// Version :over a billion
// Copyright : You wouldn't download a car would you?
// Description : convert simple entered dates into week number and Semester with year at the end.
//============================================================================
#include <iostream>
#include <cmath>
#include <string>
#include <stdio.h>
using namespace std;
class week
{
int month;
int day;
int year;
public:
week (int month = 1, int day = 1, int year = 1,int weekNum = 0,int semesterNum = 1,
double week = 0, double ineedthisnum = 0, double thisonetoo =0 )
{
week::month = month;
week::day = day;
week::year = year;
};
void showWeek();
~week(){}
};
int main()
{
int month;
int day;
int year;
//--------------------------------month----------------------------------
cout<<"Enter Date"<<endl;
cout << "Enter month (between 1 and 12)" << endl;
cin >> month;
if
(month > 12 || month < 1)
{
month = 1;
}
//--------------------------------day----------------------------------
cout << "Enter day (between 1 and 31)" << endl;
cin >> day;
if
(day > 31 || day < 1)
{
day = 1;
}
//--------------------------------year----------------------------------
cout << "Enter year (between 1900 and 2030)"<< endl;
cin >> year;
if
(year > 2030 || year < 1900)
{
year = 1900;
}
week newDate(month, day, year);
//==================================Week=================================
double week = 0.00000;
double ineedthisnum = 0.00000;
{
week = day ;
//cout<<" Week #----------> " << week<<endl;
ineedthisnum = month;
ineedthisnum = ineedthisnum * 29.6041667; //converts months to days
ineedthisnum = ineedthisnum - 29.604; //sets January to adding 0 days
week = ineedthisnum + week; //adds days to months(days)
// cout<<" Week #----------> " << week<<endl;
week = week / 365; //days divided by days in the year
//cout<<" Week #----------> " << week<<endl;
week = week * 52; //Converts to weeks in a year
//cout<<" Week #----------> " << week<<endl;
week = ceil(week); //rounds up
}
//cout<<" Week #----------> " << week<<endl;
//==================================Semester=============================
double thisonetoo = 0;
int semesterNum;
//cout<<""<< "month"<<month<<endl;
thisonetoo = month;
//converts months to temp value
//cout<<""<< thisonetoo<<endl;
thisonetoo = thisonetoo / 12; //percentage of the year past
//cout<<""<< thisonetoo<<endl;
thisonetoo = thisonetoo * 3; //numbers of semesters
//cout<<""<< thisonetoo<<endl;
thisonetoo = round(thisonetoo);
if ( thisonetoo <=0 ) //back up for low numbers
{
thisonetoo = thisonetoo + 1;
}
else
{
thisonetoo = thisonetoo*1;
}
semesterNum = static_cast<int>(thisonetoo);
//cout<<" semester #----------> " << semesterNum<<endl;
//be sure to commented out all the couts while watching the data being changed.
//=======================================================================
//cout<<"\n\n"<<month<<"/"<<day<<"/"<<year<<"\n is"<<endl;
// required output ------------------Week 5, Spring 2015
//cout<<"Week "<< week<<endl;
//cout<<"Semester "<< semesterNum<<endl;
if (semesterNum == 1)
cout<<"Week "<< week<<", Spring " << year<< endl;
else if (semesterNum == 2)
cout<<"Week "<< week<<", Summer " << year<< endl;
else if (semesterNum == 3)
cout<<"Week "<< week<<", Fall " << year<< endl;
else
cout<<"Something has gone seriously wrong!"<< endl;
return 0;
}
// Name : Assignment.cpp
// Author : Zachary Standridge
// Version :over a billion
// Copyright : You wouldn't download a car would you?
// Description : convert simple entered dates into week number and Semester with year at the end.
//============================================================================
#include <iostream>
#include <cmath>
#include <string>
#include <stdio.h>
using namespace std;
class week
{
int month;
int day;
int year;
public:
week (int month = 1, int day = 1, int year = 1,int weekNum = 0,int semesterNum = 1,
double week = 0, double ineedthisnum = 0, double thisonetoo =0 )
{
week::month = month;
week::day = day;
week::year = year;
};
void showWeek();
~week(){}
};
int main()
{
int month;
int day;
int year;
//--------------------------------month----------------------------------
cout<<"Enter Date"<<endl;
cout << "Enter month (between 1 and 12)" << endl;
cin >> month;
if
(month > 12 || month < 1)
{
month = 1;
}
//--------------------------------day----------------------------------
cout << "Enter day (between 1 and 31)" << endl;
cin >> day;
if
(day > 31 || day < 1)
{
day = 1;
}
//--------------------------------year----------------------------------
cout << "Enter year (between 1900 and 2030)"<< endl;
cin >> year;
if
(year > 2030 || year < 1900)
{
year = 1900;
}
week newDate(month, day, year);
//==================================Week=================================
double week = 0.00000;
double ineedthisnum = 0.00000;
{
week = day ;
//cout<<" Week #----------> " << week<<endl;
ineedthisnum = month;
ineedthisnum = ineedthisnum * 29.6041667; //converts months to days
ineedthisnum = ineedthisnum - 29.604; //sets January to adding 0 days
week = ineedthisnum + week; //adds days to months(days)
// cout<<" Week #----------> " << week<<endl;
week = week / 365; //days divided by days in the year
//cout<<" Week #----------> " << week<<endl;
week = week * 52; //Converts to weeks in a year
//cout<<" Week #----------> " << week<<endl;
week = ceil(week); //rounds up
}
//cout<<" Week #----------> " << week<<endl;
//==================================Semester=============================
double thisonetoo = 0;
int semesterNum;
//cout<<""<< "month"<<month<<endl;
thisonetoo = month;
//converts months to temp value
//cout<<""<< thisonetoo<<endl;
thisonetoo = thisonetoo / 12; //percentage of the year past
//cout<<""<< thisonetoo<<endl;
thisonetoo = thisonetoo * 3; //numbers of semesters
//cout<<""<< thisonetoo<<endl;
thisonetoo = round(thisonetoo);
if ( thisonetoo <=0 ) //back up for low numbers
{
thisonetoo = thisonetoo + 1;
}
else
{
thisonetoo = thisonetoo*1;
}
semesterNum = static_cast<int>(thisonetoo);
//cout<<" semester #----------> " << semesterNum<<endl;
//be sure to commented out all the couts while watching the data being changed.
//=======================================================================
//cout<<"\n\n"<<month<<"/"<<day<<"/"<<year<<"\n is"<<endl;
// required output ------------------Week 5, Spring 2015
//cout<<"Week "<< week<<endl;
//cout<<"Semester "<< semesterNum<<endl;
if (semesterNum == 1)
cout<<"Week "<< week<<", Spring " << year<< endl;
else if (semesterNum == 2)
cout<<"Week "<< week<<", Summer " << year<< endl;
else if (semesterNum == 3)
cout<<"Week "<< week<<", Fall " << year<< endl;
else
cout<<"Something has gone seriously wrong!"<< endl;
return 0;
}