![]() |
Assignment 07TaskUse conditionals to sort through the morass of Bleegian space pirate regulations.
Textbook: 5.1 - 5.2 ScenarioYou have been captured by Bleegian space pirates. The citizens of the planet Bleeg are cursed with a bloated and complicated governmental bureaucracy. Surprisingly, even those Bleegian misfits that flee their homeland to become bloodthirsty marauding space pirates have difficulty leaving their culture of rules and regulations behind. So, while every Bleegian space pirate lives only to drink, gamble, duel, and pillage, there are certain restrictions on when they are allowed to do these things. Most of these rules are imposed by each pirate vessel's Officer's Club in an attempt to maintain some control over their wild rabble crew. However, the rules can often be so complicated that the (usually drunk and belligerent) crew have difficulty remembering what activities they are allowed to do on any particular day. Bleegian space pirate vessels tend to be ancient, ill-maintained spaceships, bereft of nearly all computational hardware. However, the crew that captured you does have an old PC. When one of the officers learns that you can program, you are hauled up from the dark and fetid slave hold and set to the task of writing a program. This program must take the day of the month as input, and then display what the crew is allowed to do on that particular day. Good luck--since it's probably back into the slave hold (if you're lucky) or out the airlock (if you're not so lucky) should you fail! What you need to knowYou are given the following information, most of which is necessary to complete your program. Bleegian calendar. Space pirates still follow the calendar of their home planet. 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 each month would include: Day 0, Day 1, Day 2, ... Day 26, Day 27. Like us, Bleegians have a 7-day week. The days are, oddly, named the same as ours: Sunday, Monday, Tuesday, etc. Both the week and the month starts with Sunday. Because every month is exactly 4 weeks long, every Day 0 is always a Sunday, every Day 1 is a Monday, and so on. While Day 0 is technically a Sunday by these rules, it is a special holiday for all Bleegians. Therefore, it 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. All official regulations are specified using the dates of the standard calendar.
Dueling. Being drunk or hungover most of the time, space pirates tend to take offense easily. Because the crew was constantly challenging each other to duels to the death, dueling is now prohibited on any day except Sundays. (Festival counts as a Sunday for this rule.) Gambling. Space pirates love to gamble. Because the tally of gambling debts and loans can become quite complex, the Officer's Club likes to use Tuesdays to record and consolidate everyone's debts for the week. Therefore, no new bets can be made on that day, and so gambling is prohibited on any Tuesday. Pillaging. Of course, all these other activities just pass the time until a space pirate can go pillaging. However, given the potential deadliness of the activity, the crew tends to be a rather superstitious lot and refuses to pillage on any day divisible by four (such as Day 0, Day 4, Day 8, etc.). However, because they can't otherwise gamble on Tuesdays, the crew will disregard this rule if the day is also a Tuesday (since at least they'll get a chance to gamble their lives). The program requirementsSo that's all the background information you need. Here's what the Officer's Club says the program must actually do:
Sample OutputD:\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 may: drink duel gamble D:\TA\grading\A07>java ZtomaszeA07 Please enter the current Bleegian day of the month: -8 Today (Day 20) is Saturday. You may: gamble D:\TA\grading\A07>java ZtomaszeA07 Please enter the current Bleegian day of the month: 7 Today (Day 7) is Sunday. You may: drink duel gamble pillage What to Submit
Submit your Grading [6 points]
FAQs
|
~ztomasze Index :
TA Details: ICS111:
A07 http://www2.hawaii.edu/~ztomasze |
Last Edited: 09 Feb 2009 ©2009 by Z. Tomaszewski. |