## CSci 1001 Problem set 3. Due Thursday, March 8.

### Problem 1: Who wins elections?

Write a program that read names of two candidates as inputs, then asks you to enter the number of votes for each person, and then prints the the name of the winner. If it's a tie, it has to say so.

For instance, the dialog with the program may go like this (using prompts to read the data):

• The program asks "Please enter the name of the first candidate:", you enter "Bart Simpson"
• The program asks "Please enter the name of the second candidate:", you enter "Lisa Simpson"
• The program asks "How many votes did Bart Simposon get?", you enter 10
• The program asks "How many votes did Lisa Simposon get?", you enter 12
• The program prints "The winner is Lisa Simpson!"

If it's a tie, print something like "Bart Simpson and Lisa Simpson got equal number of votes".

### Problem 2: A fortune-teller program

Write a program that uses a random number generator to "tell fortune":

• use the function `Math.random()` to generate a random number between 1 and 5 (inclusive)
• print out the number
• pick one of 5 messages based on the number (i.e. if the number is 1, print the first message, otherwise if it's 2 then print the second one, etc.). You might want to use different colors for different messages (use ```style = "color: ..."``` for this)
• Test your program a few times to make sure that it picks each of the possible numbers

### Problem 3: Written part

Questions 13, 15, 16, 20 p 115.

### How to submit

Send all of your program files to me by e-mail. You may submit the written part in class or send it together with your problem set. Please send only ONE e-mail with your entire submission, make sure you include everything. Multiple e-mails with your homework may result in lower grade.

Your programs will be graded not just on correctness, but also on the clarity of code. Appearance of the page and creativity may be taken into account.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.