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 #2 by Ethan Castanon - basically done, need to improve a bit

// Date.h
#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


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

namespace DateSpace
{
int DateSpace::IsLeapYear(int Year)
{
int isLeap;
if ((Year % 100 == 0) && (Year % 400 == 0))
isLeap = 1;
else
if ((Year % 100 != 0) && (Year % 4 == 0))
isLeap = 1;
else
isLeap = 0;
return isLeap;
}
int DateSpace::IsValidDate(int Day, int Month, int Year)
{

if ((Month == 2) && (IsLeapYear(Year)!=1) && (0 <Day< 29))

return 1;
if ((Month==2) && (IsLeapYear(Year) == 1) && (0< Day < 30))

return 1;
if (((Month == 4) || (Month == 6) || (Month == 9) || (Month == 11)) && (0 < Day <31))

return 1;
if (((Month == 1) || (Month == 3) || (Month == 5) || (Month == 7) || (Month == 8) || (Month == 10) || (Month == 12) ) && (0 < Day < 32))
return 1;
Day = 1;
Month = 1;
Year = 1900;
return 0;
}
void Date::setDay()
{
int theDay;
std::cout << "Please enter your date's day value in integer form." << std::endl;
std::cin >> theDay;
while ( 0>=theDay || 32<=theDay)
{
std::cout << "Please enter your date's day value in integer form." << std::endl;
std::cin >> theDay;
}

while(IsValidDate(theDay,Month,Year)==0)
{
std::cout << "Error, please re-enter your date's day value in integer form." << std::endl;
std::cin >> theDay;
}
Day = theDay;
}
void Date::setMonth()
{
int theMonth;
std::cout << "Please enter your date's month value in integer form." << std::endl;
std::cin >> theMonth;
while (IsValidDate(Day,theMonth,Year)==0)
{
std::cout << "Error, please re-enter your date's month value in integer form." << std::endl;
std::cin >> theMonth;
}

Month = theMonth;

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;
while (IsValidDate(Day,Month,theYear)==0)
{
std::cout <<  "Error, please re-enter your date's year value in integer form." << std::endl;
std::cin >> theYear;
}

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


#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;
}