The Introduction to multidisciplinary Computer Science II by James Tam Return to the course web page

CPSC 219: Assignment  2

Introduction to Java Programming

New Concepts to be applied for the assignment

  1. Program documentation
  2. Input and output
  3. Formulas
  4. Decision making
  5. Looping

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).

Determining your fundex rating

Ever wonder how fun a person you are, here's your chance to find out by determining how you rate on the fun index scale "the fundex".1

Your program will ask the user three questions.  For each question a numerical 'modifier' will be calculated, each of the three modifiers will be used to calculate the overall fundex rating.

1) The person's age

2) The person's house or apartment number.

3)  The person's pet

1) Age

This value must be a positive integer between 1 and 113 (inclusive).  The age modifier will be the remainder of dividing the person's age by 100. If the user enters a value outside of this range then the program should provide an error message and assume that age is the default of 27.

2) Address

The person enters in a positive integer between 1 and 9999 (inclusive).  If the user enters a value outside of this range then the program should provide an error message and assume a default address of 4944.

The  address modifier will be equal to the remainder of dividing the address by 100.

3) Type of pet

Finally the person must indicate what type of pet that he or she owns, the values for the pet modifier are shown in the table below. If the person does not provide one of these answers then the program will automatically set the as a default value "no pet" so that the pet modifier will be set to 2. (That means that the variable storing the pet information should indicate that the person does not have a pet and the pet modifier should be determined from this value and an error message should be displayed). To keep it simple the program should accept the user's input as a single character e.g., 'n' for no pet but it should be able to handle lower or upper case values. (Run the sample executable to see how this is supposed to look).

Pet

Pet modifier
No pet 2
Fish 5
Dog 6
Cat 7
Reptile 8
Other 9
Multiple pets 10

The fundex generator will perform a calculation that is based on the answers to these three questions:

    Fundex = (age modifier + address modifier) * pet modifier

The program will then display the numerical fundex value as well as providing a text description of what the numbers mean:

Fundex value Description  
000 - 499 What a bore!
500 - 999 A genuinely fun person.
1000 - 1499 A real wit.
Over 1500 A party animal!

Finally the program will employ a loop so that each time that a calculation has been performed the program will prompt the user if he or she wishes to run the program again or if they want to exit the program.

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.

Sample executable

1 Note: The fundex is to be used for entertainment purposes only and neither I nor the University of Calgary provides any express or implicit guarantees that the numbers generated will actually predict your success at social interactions.