CST8110 – Lab Exercise 3 – Classes

$30.00

Category: Tags: , , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (2 votes)

1. Write a program that uses methods in a class in Java
• Write a class called OurDate that consists of:
o three instance variables – a month, a day and a year (each of
type int).
o a default constructor that initializes the three instance
variable to January 1, 1901.
o an initial constructor and assumes the parameter values are
correct.
o a displayDate method that displays the month/day/year (separated
by forward slashes)
• Write a test application names DateTest (with method main) that
demonstrates class OurDate’s capabilities) See sample below.
Sample program output: (user input is in red, program display in blue)
Initial date is 1/1/1901
Enter a month: 6
Enter a day: 3
Enter a year: 2013
Date is 6/3/2013
Another Sample program output
Initial date is 1/1/1901
Enter a month: 12
Enter a day: 31
Enter a year: 2011
Date is 12/31/2011