Lab 01

What is your Zodiac?

 

Objective:

 

Write a program that determines a person’s astrological zodiac sign based on their birthday.

 

Lab Solution

 

Requirements:

 

Example Dialog:

What is your zodiac?  Enter your birthday -- Month followed by Day as numbers.

5 2

You are a Taurus!

 

Another Example Dialog:

What is your zodiac?  Enter your birthday -- Month followed by Day as numbers.

-6 22

Invalid Month!

 

Another Example Dialog:

What is your zodiac?  Enter your birthday -- Month followed by Day as numbers.

12 -12

Invalid Day!

 

Another Example Dialog:

What is your zodiac?  Enter your birthday -- Month followed by Day as numbers.

9 31

Invalid Day!

 

 

Solution Tests:

 

  1. Is your name written as a comment in all source files?
  2. Does the solution compile (no syntax errors)?
  3. Given the input, 5 followed by 2 does the program print out “Taurus”?
  4. Given the input, 1 followed by 28 does the program print out “Aquarius”?
  5. Given the input, -6 followed by 22 does the program print out “Invalid Month”?
  6. Given the input, 12 followed by -12 does the program print out “Invalid Day”?
  7. Given the input, 9 followed by 31 does the program print out “Invalid Day”?

 

Lab Report

  1. Create a section named “Problem” and describe this lab’s problem in your own words. (10pts).
  2. Create a section named “Solution Description” and describe how the code solves the problem in your own words. (10pts).
  3. Create a section named “Problems Encountered” and describe the various syntax, run-time, and logic errors that were encountered while implementing the solution. (10pts).
  4. Create a flow-chart based on your lab solution. Make sure to put decisions in diamonds, statements in boxes, and draw arrows showing the flow of the program. Also, arrows coming from decisions must have the “TRUE” and “FALSE” branches clearly labeled. (10pts)
  5. Write an equivalent Boolean expression for,

 

!(a<=b)||!(b>c)

 

which applies the NOT-operator (!) to the appropriate operators.  Assume that a, b, and c are integers. (10pts)

  1. Given the following code snippet, what will the program print to the console? (10pts)

 

  1. The following code snippet appears to have a logic error. The code should print out “Yes”, but it keeps printing out “No”. What is the cause of the logic error and how can it be fixed? (10pts)

 

 

  1. The following code snippet is supposed to convert a given temperature in degrees Fahrenheit to degrees Celsius. Does this work as intended? If it does, then what should the program print out if the user provides 98 degrees. If it does not, then describe the errors and how to fix it. (10pts)

 

  1. The following code snippet contains a syntax error. Describe what is causing the syntax error and how it can be fixed. (10pts)

 

  1. Given this code snippet, what will print to the console? (10pts)

 

 

NOTE: Questions related to Code Snippets only pertain to the code that is given, and it can be assumed that all the unseen, surrounding code works. It may also be assumed that the snippet itself is in a correct location. Unless otherwise stated in the question, the code within the snippet is assumed to be error-free.

 

Finally:

Upload the source code (.JAVA File Extension) and written lab report (.DOC, .DOCX, or .PDF file extension) to the CSCE Dropbox.