Question
c++ Please correct my code: How can I pass user input from void Date::Input(int &Test) { int d, y; cout < >Test; cout < >d;
c++
Please correct my code:
How can I pass user input from
void Date::Input(int &Test) { int d, y; cout<<"Enter Month: "; cin>>Test; cout<<"Enter Day: "; cin>>d; cout<<"Enter Year: "; cin>>y; if (Test < 1 || Test > 12 || d < 1 || d > 31 || y < 1583) { cout << "Invalid date entered. Using default date: 1/1/2000"<To
void Date::Show() { cout<<"Default:"< string Date::MonthHelper(int number) { string mth; switch (number) { case 1: mth = "Jan"; break; case 2: mth = "Feb"; break; case 3: mth = "March"; break; case 4: mth = "April"; break; case 5: mth = "May"; break; case 6: mth = "June"; break; case 7: mth = "July"; break; case 8: mth = "Aug"; break; case 9: mth = "Sep"; break; case 10: mth = "Oct"; break; case 11: mth = "Nov"; break; case 12: mth = "Dec"; break; } return month_; }
For reference:
kindly note that I have created a class called Date:
class Date { private: int month; int day; int year; public: void Input(int &); void Show(); string MonthHelper(int); };Main goal is to display date in 4 forms:
Name
Format
Example
Explanation
Default
M/D/Y
10/4/1998
This will look like the input from the Input function. Print the month, day, and year as integer values.
Two-Digit
mm/dd/yy
10/04/98
Fixed size format, in which the month, day, and year values are always 2 digits Some values may need to be padded with a leading zero, and year values always show the low 2 digits.
Long
month D, Y
Oct 4, 1998
This display format should show the abbreviated month name, then the day, and the full year. Month abbreviations are Jan, Feb, Mar, Apr, May, June, July, Aug, Sept, Oct, Nov, and Dec
Julian
DDD, Y
123, 2001
This displays the Julian Date format. 123 in the Year 2001 is actually May 3rd, 2001. Leading edge zeros are not required.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started