Program 2 - Battleground states.

ANNOUNCEMENTS:
You may NOT use sys.exit() in Program 2, or in any program in this course.

The New York Times has a nice interactive electoral map. It let's the user try out scenarios, such as "What if Ohio goes for McCain?", and see how it changes the count of votes in the electoral college. We'll write a program that does something similar, without the nice graphics. As of today, they give Obama 255 likely electoral college votes, and McCain 200, and they list seven states as tossups:

Your program should ask the user to predict how each of the seven tossup states will go, and the report how the election would come out if the user's predictions come true. If the user does not enter a prediction propery for some state, your program should not count the electoral votes for that state for either candidate.

Example output

Here is an example of what running your program should look like. Blue is what Python types and black is what the user responds.

Electoral College Count
Enter your predictions!

Nevada (D or R): R

Colorado (D or R): D

New Mexico (D or R): D

Ohio (D or R): R

Virginia (D or R): R

Florida (D or R): D

New Hampshire (D or R): Bob Barr

If your predictions are correct, the electoral college counts will be:
Obama 296
McCain 238

Type enter to exit.

Getting Started

As a first step, write a program that asks for the predictions and gets the one-letter strings 'D' or 'R' from the user.

Then, worry about counting the electoral votes for the Democrats or Republicans. For this, you will probably need a variable to hold the Democrat count and another one to hold the Republican count.

Saving and handing in the program

Please name your program yourUID+"2.py", where yourUID is your myUCDavis user ID. For instance, I login to myUCDavis as "amenta", so my program is named "amenta2.py".

Like last time, hand in your assignment using myUCDavis. Select ECS 10 from your list of courses on the right. Left-click "Assignments" near the upper left, and then "Project 2". Click on "Drop-Off" and then "Browse". Get to your Desktop, and then to the "ECS 10" folder you made, and finally select your file. The file name should appear in the box next to the "Browse" button. Click "drop-off" to hand in your program.

If you are working in the computer classrooms, remember to take your ECS 10 folder, and your program, with you on your flash-drive.