13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.130 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.1313:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.13

.

.

Monday, February 14, 2011

Date Library by Ethan Castanon - basically done, need to improve a bit

// Date.h by Ethan Castanon
#ifndef Date_H
#define Date_H

namespace DateSpace
{
class Date
{
private:
int Day;
int Month;
int Year;

public:

Date()
{
Day = 1;
Month = 1;
Year = 1900;
}
int getDay(){ return Day;}
int getMonth(){ return Month; }
int getYear(){ return Year; }
void setDay();
void setMonth();
void setYear();
void ShowDate();
void CheckAnotherDate();


};

int IsValidDate(int Day, int Month, int Year);

int IsLeapYear(int Year);

}



#endif

===============================

// Date.cpp by Ethan Castanon


// File: Date.cpp; Name: Ethan Castanon
#include "Date.h"
#include <iostream>

namespace DateSpace
{
int DateSpace::IsLeapYear(int Year)
{
int isLeap;
if ((Year/1.00 == 0) && (Year/400.00 == 0))
isLeap = 1;
else
if ((Year/100.00 != 0) && (Year / 4.00 == 0))
isLeap = 1;
else
isLeap = 0;
return isLeap;
}
int DateSpace::IsValidDate(int Day, int Month, int Year)
{
int ValidDate;
if ((Month <= 0 ) || (13 <= Month))
ValidDate = 0;
if ((Day <= 0 ) || (32 <= Day))
ValidDate = 0;
if ((IsLeapYear(Year)==1) && (Month == 2) && (0 < Day < 30))
ValidDate = 1;
if (((Month == 4) || (Month == 6) || (Month == 9) || (Month == 11)) && (0 < Day < 31))
ValidDate = 1;
if (((Month == 1) || (Month == 3) || (Month == 5) || (Month == 7) || (Month == 8) || (Month == 10) || (Month == 12) ) && (0 < Day < 32))
ValidDate = 1;
return ValidDate;
}
void Date::setDay()
{
int theDay;
std::cout << "Please enter your date's day value in integer form." << std::endl;
std::cin >> theDay;


if (IsValidDate(theDay,Month,Year)==1)
Day = theDay;
else
while (theDay<= 0 || theDay>= 32)
{
std::cout << "You have committed a *violation*. The day's value is unchanged" << std::endl;
std::cout << "and remains the default day, which is 1." << std::endl;
std::cout<< "The day value you enter must be an integer value ranging from 1 to 31:" << std::endl;
std::cout << " depending on the month you entered" << std::endl;
std::cout << "Please enter your date's day value in integer form." << std::endl;
std::cin >> theDay;
}
}
void Date::setMonth()
{
int theMonth;
std::cout << "Please enter your date's month value in integer form." << std::endl;
std::cin >> theMonth;

if (IsValidDate(Day,theMonth,Year)==1)
Month = theMonth;
else
while (theMonth<= 0 || theMonth>= 13)
{
std::cout << "You have committed a *violation*. The months's value is unchanged" << std::endl;
std::cout<< "and remains the default month, which is 1." << std::endl;
std::cout<< "The month value you enter must be an integer value ranging from 1 to 12." << std::endl;
std::cout << "Please enter your date's month value in integer form." << std::endl;
std::cin >> theMonth;
}
}
void Date::setYear()
{
int theYear;
std::cout <<  "Please enter your date's year value in integer form." << std::endl;
std::cin >> theYear;

if (IsValidDate(Day,Month,theYear)==1)
Year = theYear;
}
void Date::ShowDate()
{
std::cout << "The date is: " << Month << "/" << Day << "/" << Year << std::endl;
}
void Date::CheckAnotherDate()
{
int YesNo;
std::cout << "Do you want to check another date?" << std::endl;
std::cout << "Enter the integer 1 for yes; enter integer 0 for no" << std::endl;
std::cin >> YesNo;
while (YesNo == 1)
{
DateSpace::Date theDate;
theDate.ShowDate();
theDate.setMonth();
theDate.setDay();
theDate.setYear();
theDate.ShowDate();
std::cout << "Do you want to check another date?" << std::endl;
std::cout << "Enter the integer 1 for yes; enter integer 0 for no." << std::endl;
std::cin >> YesNo;
}

}

}

=========================================

// DateDemo.cpp - demonstrate use and test Date Library


#include <iostream>
#include "Date.h"
#include "stdafx.h"

using namespace std;
using namespace DateSpace;

int _tmain(int argc, _TCHAR* argv[])
{
DateSpace::Date theDate;
theDate.ShowDate();
theDate.setMonth();
theDate.setDay();
theDate.setYear();
theDate.ShowDate();
theDate.CheckAnotherDate();
system("PAUSE");
return 0;
}