View the step-by-step solution to:

Question


startdate is 03-01-2019 enddate is 03-01-2020




/>

Screenshot1.jpgSharedScreenshot2.jpgSharedScreenshot3.jpgSharedScreenshot4.jpg

Screenshot1.jpg

New Microsoft Word Document.docx
X
Activity 2 of 3 - Boolean logic (25 points)
(this == that | | otherThing ) is legal if this, that, and
Relational
the otherThing are integer or boolean data types but it
C language
operators
expression
Logical Operators
C language
might not mean what you want it to mean.
It means TRUE if (this is the same as that OR the oth-
Equal to
a == b
negation - NOT
! ( a = = b)
erThing is non-zero/TRUE).
Not equal to
a != b
negation - NOT
! ( a != b)
It does not mean (this == that | | this == oth-
erThing) which is the way it should be written if you meant
Greater than
a > b
conjunction - AND
a > b && b > c
both expressions are true
a must be > c
to test if this is the same as either that or the otherThing.
Adding (parenthesis) will not clarify things...
Less than
a<b
disjunction - OR
a > b | | b > c
either expression is true
a may be > = < c
(this == (that | | otherThing) ) actually means if either
that or the otherThing is non-zero/TRUE, then return
Greater than
a >= b
TRUE else return FALSE, then if this is equal to TRUE, re-
or equal to
turn TRUE, else return FALSE.
Less than or
equal to
a <= b
> For any date in a year, what is the Boolean logic to de-
cide if you have to go to school during the current term?
Notes
A relational expression in programming always com-
pares one single thing to another single thing. It does not
The answer includes checking:
allow testing a range or a list, e.g.
1. Today's date compared to Academic date ranges for the
(startDate <= today <= endDate ) works for mathemat-
first and last day of classes; there are no classes during
ics, (today == startDate to endDate) and (today !=
study week; the school is closed on holidays within the
term. See the links for details. You must be here for
Saturday, Sunday ) works for humans, but neither works for
exam week which follows the last day of classes but the
C programming.
exact schedule is likely not yet known.
OFF 1-2, #67
140%
O Type here to search
Eli
9
a
w
cl's
ENG
8:57 PM
2019-10-02
75

SharedScreenshot2.jpg

IA
New Microsoft Word Document.docx
X
(this == that | | otherThing) is legal if this, that, and
2. Today's day-of-the-week (DoW) matched to your timeta-
the otherThing are integer or boolean data types but it
ble's number of classes on a day-of-the-week: does
might not mean what you want it to mean.
your timetable have classes on this day?
It means TRUE if (this is the same as that OR the oth-
3. You may have other reasons to be or not to be on cam-
erThing is non-zero/TRUE).
pus, e.g. illness.
It does not mean (this == that | | this == oth-
erThing) which is the way it should be written if you meant
Use C language comparison and logical operators and write
to test if this is the same as either that or the otherThing.
your logic in C syntax.
Adding (parenthesis) will not clarify things...
The following variables contain values for the current day-of-
(this == (that | | otherThing) ) actually means if either
the-week, today's date, and term dates:
that or the otherThing is non-zero/TRUE, then return
TRUE else return FALSE, then if this is equal to TRUE, re-
1- int Dow = today's Day of Week number: 0 is Sunday,
turn TRUE, else return FALSE.
1 is Monday, 2 is Tuesday, 3 is Wednesday, 4 is Thurs-
day, 5 is Friday, 6 is Saturday.
> For any date in a year, what is the Boolean logic to de-
cide if you have to go to school during the current term?
2- int classesDow[7] = array containing the number of
classes on each Day of Week.
Use Dow as index.
The answer includes checking:
1. Today's date compared to Academic date ranges for the
Day of Week
Sunday
Monday
Tuesday Wednesday
Thursday
Friday
Saturday
DOW index
2
4
5
6
first and last day of classes; there are no classes during
Number of
classes
n
study week; the school is closed on holidays within the
3- long today = today's calendar date YYYYMMDD
term. See the links for details. You must be here for
exam week which follows the last day of classes but the
4- long startClasses = first day of classes for this term
exact schedule is likely not yet known.
YYYYMMDD
FF 2-3, #67
140%
O Type here to search
emo
9
a
w
ENG
9:03 PM
2019-10-02

SharedScreenshot3.jpg

IA
New Microsoft Word Document.docx
X
5- long endClasses = last day of classes for this term
d. long civicDay = YYYYMMDD
// first Mon-
YYYYMMDD
day in August
6- long startStudyWeek = first day of study week for
10- Fall term holiday dates
this term YYYYMMDD
a. long thanksgivingDay = YYYYMMDD // sec-
7- long endStudyWeek = last day of study week for this
ond Monday in October
term YYYYMMDD
If your logic calls a function, your answer must include each
8- Winter term holiday dates
function's C code. For example, to determine if today's date
a. long familyDay = YYYYMMDD
// third Mon-
is or is not on a holiday, isHoliday (today ) would return
day in February
True or False - you must specify the logic inside the isHol-
iday () function.
b. long goodFriday = YYYYMMDD // depends
on lunar cycle
A relational expression in programming does not allow lists
Easter is first Sunday following the full moon follow-
of items such as
ing Spring equinox
1- DoW == Mon, Tues, Wed, Thurs, Fri
// check if on
9- Summer term holiday dates
a weekday
a. long goodFriday = YYYYMMDD // depends
2- DoW == (Mon || Tues || Wed || Thurs || Fri) // check if on
on lunar cycle
a weekday
a. should be (DOW == Mon | | DOW == Tues | | Dow
b. long victoriaDay = YYYYMMDD // third Mon-
== Wed | | ... )
day in May
3- ! DOW == (Saturday | | Sunday)
// check if
c. long canadaDay = YYYY0701
// first day of
not on a weekend
July
a. should be
Dow != Saturday && DOW !=
Sunday
4-5, #67
140%
O Type here to search
Fi
9
21
w
cl's
ENG
9:03 PM
2019-10-02

SharedScreenshot4.jpg

IA
New Microsoft Word Document.docx
X
d. long civicDay = YYYYMMDD
// first Mon-
! ( Dow == Saturday | | DOW == Sun-
day in August
day )
10- Fall term holiday dates
a. long thanksgivingDay = YYYYMMDD // sec-
There is no need to show the resolution of your Boolean ex-
pressions to TRUE or FALSE as shown in this week's slides.
ond Monday in October
If your logic calls a function, your answer must include each
function's C code. For example, to determine if today's date
is or is not on a holiday, isHoliday(today ) would return
True or False - you must specify the logic inside the isHol-
iday ( ) function.
A relational expression in programming does not allow lists
O
of items such as
1- DOW == Mon, Tues, Wed, Thurs, Fri
// check if on
a weekday
2- DOW == (Mon || Tues || Wed || Thurs || Fri) // check if on
a weekday
a. should be (DOW == Mon | | Dow == Tues | | Dow
== Wed | | ... )
3- ! DOW == (Saturday | | Sunday)
// check if
not on a weekend
a. should be
Dow != Saturday && DOW !=
Sunday
5-6, #67
-I
140%
O Type here to search
0
9
W
ENG
9:04 PM
2019-10-02

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes