Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For any given date, what is the Boolean logic to decide if you should attend school during the current term? Your c language if statement(s)

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

For any given date, what is the Boolean logic to decide if you should attend school during the current term? Your c language if statement(s) go here. There is no need to write a program. Review the following notes before writing your code. V Afterward, remove the following notes." There is no need to show the progressive resolution of your Boolean expressions to TRUE or FALSE as shown in this week's slides. The solution for this exercise is different from the presentation in this week's slides. 0 O O The answer includes checking all the following criteria. See the links for details. Is today's date within the Academic date range for the first and last day of the current term?- o The beginning of term date is usually the same as the beginning of classes. It is the first date to consider whether you should be attending school. H The end of term date is the last date you need to consider for attendance. + Does your timetable have classes on this day of the week? Use today's day-of-the-week (Dow) to check your timetable's number of classes on that day-of-the-week. See below for ways to do that. Exam week is the last week within the term: The last five business days of the term are for exams and final assessments. You must be available to attend school during that period. Note that you may not have timetabled classes during the last week of term because the exam schedule may be different from your class schedule. Exceptions to attending: - there are no classes during study week- o the college is closed on statutory holidays (no classes or exams on those days) Exclusions from consideration: o Personal reasons as to why you should or should not attend school are outside the scope of this exercise. Logic for those many possible conditions does not need to be included. e.g. you have a group meeting, or you are ill. Note that being absent for tests or exams IRL requires documentation to justify alternate arrangements...the score for a test or exam missed without a documented reason is zero. O O Use C language comparison and logical operators and write your logic in C syntax. 4 . Assume the following variables automatically contain values for the current day-of-the-week, today's date, and term dates:- int Dow = today's Day of Week number: 1 is Monday, 2 is Tuesday, 3 is Wednesday, 4 is Thursday, 5 is Friday, 6 is Saturday, 7 is Sunday.) This is the international standard ISO 8601 where Monday is the first day of the week. int classesDoW[7] = array containing the number of classes on each Day of Week. o Using ISO 8601 Dow as an array index is inconvenient for C programming where the first array element starts at zero. Why zero? int Dow_index = Dow 1; // ISO 8601 day of week number adapted for C array index, e.g. classesDow[Dow_index]+ Day of Week Monday Tuesday Wednesday Thursday Fridaye Saturday Sunday | Dow_index 02 22 34 42 62 classesDow ne n ne na 04 10 52 n 04 long today - today's calendar date YYYYMMDD- long startclasses = first day of classes for this term YYYYMMDD- long endclasses = last day of classes for this term YYYYMMDD- long startstudyweek = first day of study week for this term YYYYMMDD long endstudyWeek = last day of study week for this term YYYYMMDD- long startExamWeek = first day of exam week for this term YYYYMMDD long endExamWeek = last day of exam week for this term YYYYMMDD (this is the same date value as for endclasses) Winter term holiday dates o long familyDay - YYYYMMDD // third Monday in February o long goodFriday = YYYYMMDD Il depends on lunar cycle Easter is the first Sunday following the full moon following the Spring equinox. Summer term holiday dates o long victoriaDay = YYYYMMDD // third Monday in May o long canadaDay = YYYY0701 // first day of July long civicDay = YYYYMMDD // first Monday in August Fall term holiday dates o long labourDay = YYYYMMDD // first Monday in September (beginning of the Fall term usually follows this date and so does not need to be considered) long thanksgivingDay - YYYYMMDD // second Monday in October o O There is no need to write a C program. Although some students like to do so and it is always interesting to read a fully programed solution, there is no need to write a full C program. The solution can be written as one long Boolean statement, but it should not be for reasons of readability and maintainability. The usual professional approach would be a stepwise progression. Store decisions about individual criterion in variables. Those variables would be of type bool (boolean) and are often referred colloquially as flags which simplify each condition into 'true' or 'false'. Then check the flags in relevant combination. + Boolean variable naming is as if they were a question or an affirmative statement with a True or False response. E.g. + isHoliday means Is (today) a holiday?") isclass means Is there at least one class (on this day of the week)? | There is no perfect naming method but anything is better than flagi, check2, test3, ... For your own C99 programming outside this exercise, #include to use Boolean constants true, false, and the data type booly For any given date, what is the Boolean logic to decide if you should attend school during the current term? Your c language if statement(s) go here. There is no need to write a program. Review the following notes before writing your code. V Afterward, remove the following notes." There is no need to show the progressive resolution of your Boolean expressions to TRUE or FALSE as shown in this week's slides. The solution for this exercise is different from the presentation in this week's slides. 0 O O The answer includes checking all the following criteria. See the links for details. Is today's date within the Academic date range for the first and last day of the current term?- o The beginning of term date is usually the same as the beginning of classes. It is the first date to consider whether you should be attending school. H The end of term date is the last date you need to consider for attendance. + Does your timetable have classes on this day of the week? Use today's day-of-the-week (Dow) to check your timetable's number of classes on that day-of-the-week. See below for ways to do that. Exam week is the last week within the term: The last five business days of the term are for exams and final assessments. You must be available to attend school during that period. Note that you may not have timetabled classes during the last week of term because the exam schedule may be different from your class schedule. Exceptions to attending: - there are no classes during study week- o the college is closed on statutory holidays (no classes or exams on those days) Exclusions from consideration: o Personal reasons as to why you should or should not attend school are outside the scope of this exercise. Logic for those many possible conditions does not need to be included. e.g. you have a group meeting, or you are ill. Note that being absent for tests or exams IRL requires documentation to justify alternate arrangements...the score for a test or exam missed without a documented reason is zero. O O Use C language comparison and logical operators and write your logic in C syntax. 4 . Assume the following variables automatically contain values for the current day-of-the-week, today's date, and term dates:- int Dow = today's Day of Week number: 1 is Monday, 2 is Tuesday, 3 is Wednesday, 4 is Thursday, 5 is Friday, 6 is Saturday, 7 is Sunday.) This is the international standard ISO 8601 where Monday is the first day of the week. int classesDoW[7] = array containing the number of classes on each Day of Week. o Using ISO 8601 Dow as an array index is inconvenient for C programming where the first array element starts at zero. Why zero? int Dow_index = Dow 1; // ISO 8601 day of week number adapted for C array index, e.g. classesDow[Dow_index]+ Day of Week Monday Tuesday Wednesday Thursday Fridaye Saturday Sunday | Dow_index 02 22 34 42 62 classesDow ne n ne na 04 10 52 n 04 long today - today's calendar date YYYYMMDD- long startclasses = first day of classes for this term YYYYMMDD- long endclasses = last day of classes for this term YYYYMMDD- long startstudyweek = first day of study week for this term YYYYMMDD long endstudyWeek = last day of study week for this term YYYYMMDD- long startExamWeek = first day of exam week for this term YYYYMMDD long endExamWeek = last day of exam week for this term YYYYMMDD (this is the same date value as for endclasses) Winter term holiday dates o long familyDay - YYYYMMDD // third Monday in February o long goodFriday = YYYYMMDD Il depends on lunar cycle Easter is the first Sunday following the full moon following the Spring equinox. Summer term holiday dates o long victoriaDay = YYYYMMDD // third Monday in May o long canadaDay = YYYY0701 // first day of July long civicDay = YYYYMMDD // first Monday in August Fall term holiday dates o long labourDay = YYYYMMDD // first Monday in September (beginning of the Fall term usually follows this date and so does not need to be considered) long thanksgivingDay - YYYYMMDD // second Monday in October o O There is no need to write a C program. Although some students like to do so and it is always interesting to read a fully programed solution, there is no need to write a full C program. The solution can be written as one long Boolean statement, but it should not be for reasons of readability and maintainability. The usual professional approach would be a stepwise progression. Store decisions about individual criterion in variables. Those variables would be of type bool (boolean) and are often referred colloquially as flags which simplify each condition into 'true' or 'false'. Then check the flags in relevant combination. + Boolean variable naming is as if they were a question or an affirmative statement with a True or False response. E.g. + isHoliday means Is (today) a holiday?") isclass means Is there at least one class (on this day of the week)? | There is no perfect naming method but anything is better than flagi, check2, test3, ... For your own C99 programming outside this exercise, #include to use Boolean constants true, false, and the data type booly

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

User Defined Tensor Data Analysis

Authors: Bin Dong ,Kesheng Wu ,Suren Byna

1st Edition

3030707490, 978-3030707491

More Books

Students also viewed these Databases questions

Question

Identify the cognitive roots of prejudice.

Answered: 1 week ago

Question

1. Organize and support your main points

Answered: 1 week ago

Question

3. Move smoothly from point to point

Answered: 1 week ago

Question

5. Develop a strong introduction, a crucial part of all speeches

Answered: 1 week ago