Comp 110 Alert CAROLina

PS01 - Alert CAROLina

Alert CAROLina Intro

In a world where temperatures can drop below freezing and a quarter inch of snow can accumulate overnight, there is only one heroine who can save us all. The people call her Carol. When the weatherman predict an off chance of snow it is not fear that grips her, only a heightened sense of things. With a little help from your code, Rameses, and Roy, Carol will bravely traverse the treacherous brick paths of campus in order to find the Alert Carolina button. With the flick of a finger Carol can emit an aura of safety throughout the lands, as thousands of cell phones stir buzzing with life, illuminated, and aware of the snow that is yet to come.

In this problem set, you will calculate the Alert Carolina Risk Score (tm), guide Carol across campus to find the Alert Carolina Button's Unlock Code, and finally press the button to ensure the safety of us all.

Step 0) Import the Support Code for PS1

To get started, follow these steps to install the Support Code for PS00.

  1. Start Eclipse
  2. Select and copy the following link to your clipboard:
  3. Click the File menu
  4. Select "Import"
  5. Double click "Git" to expand the folder
  6. Double click "Projects from Git"
  7. Double click "Clone URI".
  8. The "URI" field should already have the URI you copied in Step 2 in it. If it does not, paste the URI from step 2 in it. Click next.
  9. Ensure there's a check beside of "master". Click next.
  10. In the "Directory" field, click "Browse". Navigate to your documents folder and select the COMP110 folder. Click next.
  11. Ensure "Import existing Eclipse projects" is selected. Click next.
  12. Ensure the correct Problem Set folder is checked. Click finish.

Part 1) Alert CAROLina Risk Calculator

Open: src > comp110 > - go ahead and fill in the header with your name and ONYEN.

The purpose of this program is to build a calculator for assessing wintery weather risk. In this part of the problem set you will make use of the Console, variables, and expressions as covered in lectures 1 and 2.

Your task is to prompt the user for three double values, in this order:

1. Temperature in Fahrenheit
2. Inches of snow fallen
3. Inches of snow projected

Here is a screenshot after the user has entered #1 and #2:

With these three data points, you will then need to write the code to calculate and produce the following three lines of output:

Temperature (C): <temperature in celsius>
Total Snow (cm): <snow fallen + snow projected in centimeters>
Alert Carolina Risk Score: <risk score formula below>

The formulas you will need for conversion and risk scores are as follows:

Fahrenheit to Celsius Formula

Be careful to use double literals in this conversion!

Inches to Centimeters Formula

cm = in * 2.54

Alert Carolina Risk Score Formula

risk = -1.0 * t + 5.0 * s
t is temperature in celsius
s is total snow (fallen + projected) in centimeters

For example, here is an example output when the inputs were 32.0 fahrenheit, 1.0 inches of snow fallen, 0.5 inches of snow projected:

Here are some other example data points for you to test your program with:

Example Data 1
    Temperature (f): 75.0 
    Inches of snow fallen: 0.0    
    Inches of snow projected: 0.0
    Temperature (C): 23.888888888889
    Total Snow (cm): 0.0
    Alert Carolina Risk Score: -23.888888888889
Example Data 2
    Temperature (f): 22.0 
    Inches of snow fallen: 1.0
    Inches of snow projected: 3.0
    Temperature (C): -5.5555555555
    Total Snow (cm): 10.16
    Alert Carolina Risk Score: 56.35555555554

Any Alert Carolina Risk Score above 0.0 gives Carol clearance to send an immediate warning to protect our lives from imminent danger. Once your calculator is complete, move to Part 2 where you will help guide Carol the Alert Carolina button on campus using method calls.

Part 2) Carol Quest

The situation is dire. It is 32 degrees outside and although there is no snow on the ground, there is a quarter inch of snow projected. With a Risk Score of 3.175 it is vital that Carol sends out a warning. For reasons unknown, the location of the button's unlock code is only known by Roy Williams and only Rameses knows where Roy is. Ultimately this quest will leave you with the unlock code Carol needs to send an alert which you will do in Part 3.

Important Notes and Common Problems

1. Be careful you are navigating to the building with the exact same name on campus! You should see Rameses or Roy "above" the building you are looking for once you get there. Specifically: Graham Memorial is a building located on the upper quad. 

2. Carol must be on top of the blue part of the building in order to interact with Rameses or Roy. This is important if your Rameses is at Kenen StadiumIf Rameses is at Kenan, Rameses will appear in the field but you need Carol to be on top of the building.

To begin, open Fill in the header fields appropriately. Then change the String that says "insert your onyen here!" to be a String only containing your ONYEN. For example, "krisj".

Now you're ready to send send Carol instructions to guide her around campus. Begin by running the program. Then try writing some code to give her commands to make her move (possible commands below). The general format for calling a method is this:

<object "noun">.<method "verb">(<arguments i.e. the "extra information" needed>);
// Examples you can try:

Here are the methods of the class Chancellor, in alphabetical order.

Chancellor's methods / "commands"

  • void getAlertCarolinaCode() - Carol will press the mythical Alert Carolina button if she is close enough.
  • void moveForward(int steps) - Moves Carol forward a given amount of steps.
  • void mountRameses() - You must be standing on the blue part of the *building* Rameses is at (for Kenan Stadium, see common problem note written above). Carol will mount UNC's beloved mascot to ride around campus in search of the Alert Carolina button. Carol and Rameses move faster than Carol alone. (Note: No Rameses were harmed in the making of this problem set.)
  • void talkToRoy() - Carol will speak with Roy Williams and inquire about the location of the Alert Carolina button if she is close enough.
  • void turnLeft(int degrees) - Turns Carol left a given number of degrees.
  • void turnRight(int degrees) - Turns Carol right a given number of degrees.

We will discuss how to read this kind of documentation for methods in class. Ignoring the void, the only thing to note is where you see the <type> <name> pattern within parenthesis means you must provide a value of that type here.

Having problems? Need help? Come to office hours! We're in Sitterson 008 from 10am - 8pm Monday through Thursday, 10am - 6pm Friday, and 12pm - 5pm on Sunday.

Part 3) Unlock the Alert Carolina Button

Now that you know your unlock code, your last step is to unlock the Alert Carolina button and press it!

Begin by filling in your name and ONYEN in the header.

Then, you'll need to give the button your ONYEN and your unlock code. There are two method calls already in place for you to do so, just change the values of the Strings.

Finally, run the program and press the red button. Congrats on making it through PS1 and saving Carolina!! 

Submit your Solution

This problem set is due Friday 1/27 at 11:59PM. Online grading will open by Monday 1/23. Once it does, you will want to follow the usual submission procedures found here. Be sure to fill in your name and onyen in the headers of all three Java files!

Value: 300 Points

Notes & Warnings!

  • Start EARLY! This assignment will take longer than making a dank meme. It's about 20-30x more code to write. Relative to later projects, it's still on the smaller side, but save yourself stress by starting early and coming to office hours for help if you get stuck.