Back to 111 Main Page

Mobius strip

Assignment 07


Use conditionals to sort through the morass of Bleegian bureaucracy. (This program will be the basis of our first studio: see "What to submit", below.)

Concepts: comparison operators; if, else, else if, (switch); logical operators
Textbook: 5.1 - 5.2

Setting [flavor]

Bleeg is a small, remote planet cursed with a bloated governmental bureaucracy. In a recent attempt at reform, the myriad administrative offices and departments were combined into three massive agencies:

  • The Bureau of Wholesome Citizenship tracks citizen's legal and financial infractions, including everything from criminal records, to credit reports, to overdue library fines. All of its forms are blue.
  • The Health and Well-being Agency oversees all things related to health and medical care. All of its forms are pink.
  • The Consolidated Ministry of Administration--the largest of the three--handles all other administrative issues, from building permits, to ID cards, to vehicle registration. All of its forms are white.

Its long history of excessive paperwork has strained Bleeg's natural resources. For this reason, citizens must present ID to pick up forms at any of the three departments. Additionally, before any white forms can be turned in, current pink and blue forms must also be completed in order to prove the applicant is a healthy, viable member of society (and so worth the expense of the various forms they will have to complete).

As if this were not enough hassle, each of the departments are open on different days. And the CMA will only give out forms on some days and accept returned forms on other days.

However, computers are just being introduced to Bleeg. Through a series of sordid events (it's a long story), you are currently serving time in the Bleegian programming pits. It has fallen to you to implement the first program meant to cut through the Bleegian bureaucracy: a program that will tell citizens which forms they can pick up or turn in on any given day.

What you need to know [requirements]

Bleegian calendar. The Bleegian year of 364 days is divided into 13 months of exactly 28 days each. Bleegians start counting days of the month at 0, however. So a month would include: Day 0, Day 1, Day 2, ... Day 26, Day 27.

Like us, Bleegians also have a week of 7 days. The days are, oddly, named the same as ours: Sunday, Monday, Tuesday, etc. The week starts with Sunday. Because every month is exactly 4 weeks long, every Day 0 is a Sunday, every Day 1 is a Monday, and so on.

Actually, while Day 0 is technically a Sunday, it is a special holiday for all Bleegians and is always called Festival. (Day 7, Day 14, and Day 21 are all normal Sundays.)

To further complicate matters, some Bleegian's prefer to number days from the end of the month, rather than the beginning. To prevent total confusion, dates in this "count-down" calendar are given as negative numbers. Therefore, Day -1 == Day 27, Day -2 == Day 26, Day -3 == Day 25, and so on. Luckily, both the standard and the count-down calendars coincide on Day 0.

Department days. Here are the details of the departments:

  • All departments follow the standard calendar. (That is, the following rules are only true for positive days.)
  • Regardless of its other rules (given below), no department is open on Festival (Day 0).
  • The CMA (white forms) is open every day of the month. However, they only allow citizens to pick up forms on odd days (Day 1, Day 3, etc.), and turn in forms on even days (Day 2, Day 4, etc.)
  • The HWBA (pink forms) is closed every third day (Day 3, Day 6, Day 9, etc.) That is, they are closed if the day is divisible by 3.
  • The BWC (blue forms) is open every even day (Day 2, Day 4, etc), unless that day falls on a 5th day (Day 5, Day 10, etc), in which case they're closed. That is, they're open only if the days is divisible by 2 and not by 5.

The program requirements.

  • The program should ask the user to enter the current day of the month. It needs to support both the standard and the count-down calendar. (So any value between -27 and 27 is valid.)
  • If the user enters an invalid number, give an error message (and no other output).
  • If the number is in the valid range, print the current day of the week. (Remember Day 0 is Festival, Day 1 is Monday, Day 2 is Tuesday, and so on.)
  • Also print the current day in the standard calendar.
  • Then list which colored forms are available for pick up today. (Allowed synonyms for pick up include: get, collect, request. This list should be on one line, but the order of the forms does not matter.)
  • Then list which colored forms can be dropped off today. (Allowed synonyms for drop off include: return, submit. Again, this list should also be on one line, and the order of the forms does not matter.)

Remember, the Bleegian jute mills await you should you fail at this task!


Here is some sample output of a few runs:

D:\TA\grading\A07>java ZtomaszeA07
Please enter the current Bleegian day of the month: 30
Sorry, but 30 is not a valid day of the month.

D:\TA\grading\A07>java ZtomaszeA07
Please enter the current Bleegian day of the month: 0
Today (Day 0) is Festival.
You can pick up no forms today.
You can drop off no forms today.

D:\TA\grading\A07>java ZtomaszeA07
Please enter the current Bleegian day of the month: -8
Today (Day 20) is Saturday.
You can pick up these forms: pink
You can drop off these forms: pink white

D:\TA\grading\A07>java ZtomaszeA07
Please enter the current Bleegian day of the month: 14
Today (Day 14) is Sunday.
You can pick up these forms: pink blue
You can drop off these forms: pink blue white

D:\TA\grading\A07>java ZtomaszeA07
Please enter the current Bleegian day of the month: 3
Today (Day 3) is Wednesday.
You can pick up these forms: white
You can drop off these forms:

What to Submit

Upload your file to Tamarin.

Note the A07a designation. We will hold a studio on this assignment, meaning other students will get a chance to review your code, and you will get to review theirs. Then, you will have one week to make any revisions you want and then (optionally) submit A07b. For your final A07 grade, I will average your A07a and A07b grades (if you submit A07b).

To resubmit after the studio, upload your file to Tamarin

Grading [6 points]

1 - Compiles
Your program compiles successfully (no errors)
1 - Input
You read in the Bleegian day of the week (int) from the user.
1 - Error-checking and conversion
You report if the entered day is out of range (0.5). You convert negative "count-down" dates to standard dates (0.5).
1 - Day of the week
You print the correct day of the week.
2 - Pick-up/Drop-off forms
You correctly print which forms can be picked up or dropped off on the given day. Note the output formatting requirements above.


What, no hints?
Well, okay, here's what I'd recommend: Error check the input first. If it's in range, convert count-down (negative) days to standard (positive) days. Then determine which day of the week it is. This should only require eight cases (not 28!): one for each day of the week and an extra one for Day 0 (which is "Festival").

Note that calculating the day of the week is not related to determining what forms are available. To determine the forms, note that, at this point, this is really just a "what is the day number divisible by?" problem. You may want to use some boolean variables to hold the results of whether you can pick up or drop off each color form.

~ztomasze Index : TA Details: ICS111: A07
Last Edited: 30 Sep 2008
©2008 by Z. Tomaszewski.