Introduction to Computer Science II for non-majors by James Tam

Return to the course web page

CPSC 219: Assignment 1

Due January 27 at 4 PM.

New Concepts to be applied for the assignment

Aside from the 'main' method you are not to write static methods for this assignment. (If you don't know what I'm referring to by static methods, I will be discussing this topic later in the course).

Introduction

Write a program that will prompt the user for their birth month and the day of the month that the person was born. If a numeric value outside of 1 - 12 was entered for the month then the program should indicate that only a value from 1 - 12 is valid for the month and re-prompt for the information until a valid value has been entered. Your program does not have to handle cases where the user enters the name of the month (e.g., 'Mar', 'November' etc.) rather than a numeric value. Once a valid month has been entered then the program should prompt the user for the day of the month that they were born. The program should re-prompt for the day if an invalid value (<1) or (>31) has been entered or if the day of the month entered exceeds the maximum number of days in a particular month (e.g., a person can't be born on the 30th of February). You don't have to worry about the effect of a leap year for this assignment.

Finally the program should then display the user's astrological sign which is determined by the day/month that he or she was born. For your reference here is the mapping:

Capricorn Aquarius Pisces Aries Taurus Gemini Cancer Leo Virgo Libra Scorpio Sagittarius
Dec 22 -  Jan 19 Jan 20 - Feb 18 Feb 19 - Mar 20 Mar 21 - Apr 19 Apr 20 - May 20 May 21 - Jun 21 Jun 22 - Jul 22 Jul 23 - Aug 22 Aug 23 - Sep 22 Sep 23 - Oct 22 Oct 23 - Nov 21 Nov 22 - Dec 21

Submitting your work:

  1. Assignments (source code/'dot-java' files) must be electronically submitted according to [the assignment submission requirements].
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].
  3. Before you submit your assignment to help make sure that you haven't missed anything here is a [checklist] of items to be used in marking.

External libraries that can be used

  1. Libraries that allow for text-based (console) input and output.