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.
To get started, follow these steps to install the Support Code for PS00.
Open: src > comp110 > AlertCarolinaCalculator.java - 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 Where: 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 Inputs: Temperature (f): 75.0 Inches of snow fallen: 0.0 Inches of snow projected: 0.0 Outputs: Temperature (C): 23.888888888889 Total Snow (cm): 0.0 Alert Carolina Risk Score: -23.888888888889 Example Data 2 Inputs: Temperature (f): 22.0 Inches of snow fallen: 1.0 Inches of snow projected: 3.0 Outputs: 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.
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 Stadium. If Rameses is at Kenan, Rameses will appear in the field but you need Carol to be on top of the building.
To begin, open CarolQuest.java. 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 CarolQuest.java 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: carol.turnLeft(20); carol.moveForward(10);
Here are the methods of the class Chancellor, in alphabetical order.
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.
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!!
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