April 6, 2006
I have school project that I am working on. I got it to run and it displays the first form. The problem is that I am having trouble figuring out how to get to to display all three forms I need. Here are the 3 forms:
12/25/2005
December 25, 2005
25 December 2005
I got it to display 12/25/2005. I'm trying to figure out how to get it to dislplay the last 2 forms. Below is what I have so far:
//This program demonstrates a simple class.
#include <iostream>
using namespace std;
const int MONTH_SIZE = 2;
const int DAY_SIZE = 2;
const int YEAR_SIZE = 5;
// Date class declaration.
class Date
{
private:
double month;
double day;
double year;
public:
void setMonth(double);
void setDay(double);
void setYear(double);
double getMonth();
double getDay();
double getYear();
};
// setMonth assigns its argument to the private member month.
void Date::setMonth(double m)
{
month = m;
}
// setDay assigns its argument to the private member day.
void Date::setDay(double d)
{
day = d;
}
// setYear assigns its argument to the private memter year.
void Date::setYear(double y)
{
year = y;
}
// getMonth returns the value in the private member month.
double Date::getMonth()
{
return month;
}
// getDay returns the value in the private member day.
double Date::getDay()
{
return day;
}
// getYear returns the value in the private member year.
double Date::getYear()
{
return year;
}
// Function main
int main()
{
Date box; // Define an instance of the class.
double dateMonth, // Local variable for month.
dateDay, // Local variable for day.
dateYear; // Local variable for year.
// Get the date from the user.
cout << "Now enter the date. \n";
cout << "Month (up to 2 digits): ";
cin >> dateMonth;
cout << "Day (up to 2 digits): ";
cin >> dateDay;
cout << "Year (up to 4 digits): ";
cin >> dateYear;
// Store the month, day and year in the box object.
box.setMonth(dateMonth);
box.setDay(dateDay);
box.setYear(dateYear);
// Display results.
cout << "Date: ";
cout << box.getMonth() << "/";
cout << box.getDay() << "/";
cout << box.getYear() << endl;
system("pause");
return 0;
}
I need help! :confused:
Janito2008