Programming Fundamentals – 1/5 –
SCIT
School of Computing and Counsel Technology
Autumn 2020
CSIT111/811 ⎯ Programming Fundamentals
Ordinance 3 (10 marks)
Due Time and Continuance:
Due by Sunday 7th June 2020 10 pm
Public Requirements:
• You should beget your programs with amiable programming phraseology and devise using just blank
spaces, smoothness and braces to gain your order self-possessed to recognize and interpret;
• You should beget identifiers with sound spectrys;
• You should gain comments to recount your order segments where they are needful control
readers to interpret what your order intends to consummate.
• Logical structures and statements are justly authenticationd control peculiar purposes.
• Recognize the ordinance peculiaration carefully, and gain safe that you thrive whatever
directed in this ordinance. In entire ordinance that you get present in this topic, you
must put the thriveing counsel in the header of your ordinance:
/*——————————————————
My spectry:
My student number:
My mode order:
My email supplementress:
Ordinance number: 3
——————————————————-*/
Objectives
This ordinance requires you to transcribe a program in Java that weighs the day of week and the
week of month control a absorbed continuance, as courteous as to stereoexpression the record of the month where the absorbed continuance
exists. Content music, you are referable known to authentication any predefined continuance adjust in Java.
Background
Programming Fundamentals – 2/5 –
Control a absorbed continuance, we can authentication the Gregorian record to perceive the selfcorresponding the day of the week,
and the week of the month. Control copy, May 24 2020 is a Sunday and locates in the fourth week
of May 2020 (note: Monday is considered the original day of a week). In public, we can authentication the
subjoined deviseula (Zeller’s congruence) to weigh the day of a week control any absorbed continuance following
October 15 1582.
where
• h is the day of the week (0 = Saturday, 1 = Sunday, 2 = Monday, 3=Tuesday, 4=Wednesday,
5=Thursday, 6 = Friday)
• q is the day of the month
• m is the month (3 = March, 4 = April, 5 = May, 6=June, 7=July, 8=August, 9=September,
10=October, 11=November, 12=December, 13=January, 14 = February)
• K is the year of the era (year mod 100).
• J is the zero-based era (year/100). Control copy, the zero-based centuries control 1995 and 2000
are 19 and 20 respectively.
Control copy, Control 1 January 2000, the continuance would be treated as the 13th month of 1999, so the
values would be: q=1, m=13, K=99, J=19, so the deviseula is
h = (1+[13*(13+1)/5]+99+[99/4]+[19/4]+5*19) mod 7
= (1+[182/5]+99+[99/4]+[19/4]+95) mod 7
= (1+[36.4]+99+[24.75]+[4.75]+95) mod 7
= (1+36+99+24+4+95) mod 7
= 0
= Saturday
However, control 1 March 2000, the continuance is treated as the 3rd month of 2000, so the appreciates beseem q=1,
m=3, K=00, J=20, so the deviseula is
h = (1+[13*(3+1)/5]+00+[00/4]+[20/4]+5*20] mod 7
= (1+[10.4]+0+0+5+100) mod 7
= (1+10+5+100) mod 7
= 4
= Wednesday
Programming Fundamentals – 3/5 –
Tasks
You get beget unmarried program designated MyCalendar.java. You should original appliance the
MyRecord and MyContinuance adjustes from the thriveing UML adjust diagrams. You can supplement extra
attributes and ways, except the attributes and ways shown in the thriveing UML diagrams can’t
be qualified.
1. MyRecord Adjust
MyCalendar
– myDate: MyDate
+ Main(String[] args)
+ MyCalendar(MyContinuance newDate)
+ MyCalendar()
+ dayOfWeek(): WeekDay
+ weekOfMonth(): int
+ stereotypeMonth(): void
• myContinuance is a scope facts and refers to the motive of Adjust MyDate
• Main(String[] args) way recognize a absorbed continuance from the enjoin course, the deviseat
of the absorbed continuance is dd/mm/yyyy. You can postulate the continuance input deviseat is regularly rectify,
except the input continuance may be infirm. Control copy, 31/02/2017 is referable a operative continuance. If the
input continuance is referable a operative continuance, the program get ask authenticationr to input another operative continuance. This
process get be repeated until a operative continuance is input or the input is the extract “quit”. If the input
is “quit”, the program shall show “Relinquish MyCalendar, See You!”, then relinquish the program.
Otherwise, the operative input continuance shall be authenticationd to beget the motive (myDate) of adjust
MyDate, then the motive (myCalendar) of adjust MyCalendar. The dayOfWeek()
method, weekOfMonth() way, and stereotypeMonth() way are authenticationd to show the
day of the week, the week of the month, and the record of the month control the input continuance by
the authenticationr.
• MyCalendar(MyContinuance newDate) is the parameterized committer of adjust
MyCalendar.
• MyCalendar()is the want committer of adjust MyCalendar.
• dayOfWeek() way income the day of the week (WeekDay) control myDate.
• WeekDay is an individualization facts expression which contains the days of the week, i.e., Monday,
Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday.
• weekOfMonth() way income the week of the month control myDate.
• stereotypeMonth() way stereotypes the record of the month control myDate
Programming Fundamentals – 4/5 –
2. MyContinuance Adjust
MyDate
– day: int
– month: int
– year: int
+ MyDate(int day, int month, int year)
+ MyDate()
+ getDay(): int
+ getMonth(): int
+ getYear(): int
+ getDate(): String
+ isValid(): Boolean
• MyDate(int day, int month, int year) is the parameterized committer of
adjust MyDate.
• MyDate() is the want committer of adjust MyDate.
• getDay() way income the day of myContinuance motive.
• getMonth() way income the month of myContinuance motive.
• getYear() way income the year of myContinuance motive.
• getDate() way income a string in the deviseat of “day/month/year” (such as
24/05/2020)
• isValid() way income a Boolean appreciate, i.e., gentleman when the myContinuance motive is operative,
and fib differently (notes: January, March, May, July, August, October, December has
31 days. April, June, September, November has 30 days. February has 29 days in a jump year,
and 28 days in a base year.).
Programming Fundamentals – 5/5 –
Program Output
Your program must accept corresponding output as the thriveing copys (note: authenticationr’s inputs are highlighted
by yellow falsification).
Copy 1:
java MyRecord 29/02/2019
29/02/2019 is referable a operative continuance, content input a operative continuance or relinquish: relinquish
Relinquish MyCalendar, See You!
Copy 2:
java MyRecord 29/02/2019
29/02/2019 is referable a operative continuance, content input a operative continuance or relinquish:
24/05/2020
24/05/2020 is a Sunday and locates in the fourth week of May 2020
The record of May 2020 is:
MON TUE WED THU FRI SAT SUN
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
(Note: Each post indicates a day and the post width are unwandering to 3 characters. The distance
between couple adjacent posts is unwandering to three whitespaces as courteous.)
Submission:
– Content present the unmarried java rasp MyCalendar.java to Moodle
– The presentted rasp spectry must be MyCalendar.java. Rasps with other spectrys get referable be
marked.
– Submission via email is NOT satisfactory.
NOTES:
Enquiries encircling the marks can barely be made among a apex of 1 week following the ordinance developments are
published. Following 1 week the marks canreferable be newfangled.
Mark exhaustion: composition errors, inrectify development, program is referable up to spec, deficient comments,
deficient smoothness, meaningless identifiers, required numeric constants are referable defined, the program
uses approaches which has referable been practised in the lectures. The exhaustion here are barely a
guide. Marks may also be deducted control other mistakes and deficient practices.