THIS IS THE CODE THAT I HAVE. CAN SOMEONE HELP ME MODIFY IT THE CODE N MAKE IT W
ID: 441165 • Letter: T
Question
THIS IS THE CODE THAT I HAVE. CAN SOMEONE HELP ME MODIFY IT THE CODE N MAKE IT WORKING BECAUSE IT NOT WORKING PLEASE.
THANKS
#include <iostream>
#include<iostream>
#include<vector>
using namespace std;
class Date
{
private:
int Year;
int Month;
int Day;
public:
Date();
void setDate(int y,int m,int d);
void DisplayNumerically() const;
void DisplayTextually() const;
};
int main()
{
Date mydate;
mydate.setDate(1,11,2011);
mydate.DisplayNumerically();
mydate.DisplayTextually();
return 0;
}
Date :: Date ()
{
Year = 0;
Month = 0;
Day = 0;
}
void Date::setDate(int y, int m, int d)
{
Year = y;
if(m >= 1 && m <= 12)
{
Month = m;
}
else
{
cout << "Month is invalid." << endl;
}
if(m == 1|| m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
{
if(d >= 1 && d <= 31)
Day = d;
else
cout << "Day is Invalid." << endl;
}
else if(m == 2)
if(d >= 1 && d <= 28)
Day = d;
else
cout << "Day is Invalid." << endl;
else if(m == 4 || m == 6 || m == 9 || m == 11)
{
if(d >= 1 && d <= 30)
{
Day = d;
}
else
{
cout << "Day is Invalid." << endl;
}
}
}
void Date::DisplayNumerically() const
{
cout << "Numerical Display:" << endl;
if (Month <= 9)
cout << "0" << Month << "/" << Day << "/" << Year << endl;
else if(Month >= 10)
cout << Month << "/" << Day << "/" << Year << endl;
cout << endl;
}
void Date::DisplayTextually() const
{
string MonthList[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
cout << "Text Display:" << endl;
for(int i = 0;i < 12;i++)
{
if((Month-1) == i)
{
cout << MonthList[i] << "/" << Day << "/" << Year << endl;
}
}
cout << endl;
}
Explanation / Answer
please post the errors ill help you ill debug it and fix it for you can you please meanwhile rate the answer?
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.