Convert the following numbers from binary (base 2) to decimal (base 10). All numbers are positive.
Convert the following numbers from decimal to binary.
Convert the following numbers from hexadecimal (base 16) to decimal.
Convert the following numbers from decimal to hexadecimal
Exercises 18, 19, 20, 22 p. 229.
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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
And the winner is...
</title>
<script type="text/javascript" language="javascript">
function determineTheWinner() {
v1 = parseFloat(document.theform.votes1.value);
// add the rest of the function here
}
</script>
</head>
<body>
<h1>And the winner is...</h1>
<p>Please enter names of two people and how many votes each person got.</p>
<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>
</form>
</p>
</body>
</html>
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.