Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C#, Write a program with a Date struct, that contains: Three fields: year, month, and day. All are int type. Two constructors: a. public

Using C#,

Write a program with a Date struct, that contains:

Three fields: year, month, and day. All are int type.

Two constructors:

a. public Date(int year, int month, int day) - takes three parameters, and assigns corresponding values in the struct.

b. public Date(string dateString). - takes a date string with format mm/dd/yyyy, such as 06/05/2017. You need to parse the string.

One method public void PrintInfomation() - It prints out the date information on the Console with the following format Today is Jun, 05, 2017.

In the Main method, first read an instruction number from the console, with option of 1 and 2.

1) For option 1, the program creates a Date struct using constructor a. User will then type in date information separated by spaces ( ), as 2017 06 05. The date information is printed using PrintInfomation() method.

2) For option 2, the program creates a Date struct use constructor b. User will then type in date information in the format of 06/05/2017. The date information is printed using PrintInfomation() method.

Example 1 (Bold lines are input):

1

2017 06 05

Today is Jun, 5, 2017

Example 2:

2

06/05/2017

Today is Jun, 5, 2017

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

explain what is meant by the terms unitarism and pluralism

Answered: 1 week ago