CSci 1001 Problem set 5. Due Thursday, November 20th.

Problem 1 (10 points)

Convert the following numbers from binary (base 2) to decimal (base 10). All numbers are positive.

  1. 10011
  2. 111
  3. 10100

Convert the following numbers from decimal to binary.

  1. 1
  2. 23
  3. 30

Convert the following numbers from hexadecimal (base 16) to decimal.

  1. A1
  2. 4B

Convert the following numbers from decimal to hexadecimal

  1. 88
  2. 139

Problem 2 (8 points)

Exercises 18, 19, 20, 22 p. 229.

Problem 3 (8 points): determine the winner using a function

Write a JavaScript program to determine the winner of an election. The page must have a form to enter names of two candidates and their corresponding votes. When the button is clicked, display the winner and the number of votes in the text area.
Below is the starting point for the problem. save it to a file and add the missing elements. Note that since the form gives you strings, not numbers, you need to use parseFloat as shown below to use the form data as numbers.

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html  xmlns="" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
And the winner is...
<script type="text/javascript" language="javascript">
function determineTheWinner() {
    v1 = parseFloat(document.theform.votes1.value);
    // add the rest of the function here

<h1>And the winner is...</h1>
<p>Please enter names of two people and how many votes each person got.</p>  
<form name="theform">
The first candidate: 

<input type="text" name="first" size=10 value="Bart Simpson" /><br />
The first number of votes: 
<input type="text" name="votes1" size=10 value="0" /><br />
<br />
<input type="button" value="Click me" 
       onClick="determineTheWinner();" />
<br />
<textarea name="winner" rows="2" cols="80" wrap="virtual"></textarea>

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.