CSci 1001 Problem set 3. Due Thursday, October 23 at 2pm.

Problem 1 (6 points): history of computers

Questions 14, 15, 18 p. 113.

Problem 2 (8 points): Elections result

Write a program that reads the names of two candidates, 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):

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

Problem 3 (10 points): fix a mistake in the program

The following program converts percent values into letter grades (with the 10% scale, i.e. 90-100 is A, 80-89 is B, etc.). It works, but has mistakes in its logic so it gives wrong results for some inputs.
You may assume that the number entered is always between 0 and 100. There are no "plus" or "minus" grades, such as B-.

Your task is as follows:
  1. Give at least two examples of data for which it gives incorrect results, clearly explain why (list the specific comparisons that the data goes through in each example)
  2. Fix the mistakes. You might want to change the comparison part quite a bit. Make your correct program very clear.
  3. Test your program to make sure that it works correctly (try the inputs that were working in the wrong version to make sure that they still work). Write down what data you tested it with
  4. What would be your advice on how to avoid similar mistakes in conditionals in the future?

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
an INCORRECT program for converting from numeric 
to letter grades for CSci 1001 problem set
Author: Elena Machkasova
Last modified: 10/16/2008
<html  xmlns="" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
Fix this program!
<h1>Converting to letter grades</h1>
<script type="text/javascript" language="javascript">
var numeric = window.prompt("Please enter your numeric grade: ", "");
numeric = parseFloat(numeric);

if (numeric > 90) {
	document.write("Your letter grade is A");
} else if (numeric < 80)  {
	document.write("Your letter grade is C");
} else if (numeric < 70)  {
	document.write("Your letter grade is D");
} else if (numeric < 60)  {
	document.write("Your letter grade is F");
} else {
	document.write("Your letter grade is B");


Problem 4 (4 points): real-life algorithms

Ex. 11 p. 154. Include a printout, a photocopy, or a scan of each of the two algorithms, mark parts of it that you think are unclear and parts that you think are clear, briefly explain why.

How to submit

Send all of your program files to me by e-mail. You may submit the written part (if any) 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 a lower grade.

CSci 1001 course web site.

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.