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".
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-.
<!DOCTYPE html>
<!--
an INCORRECT program for converting from numeric
to letter grades for CSci 1001 problem set
Author: Elena Machkasova
Last modified: 10/16/2008
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
Fix this program!
</title>
</head>
<body>
<h1>Converting to letter grades</h1>
<p>
<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");
}
</script>
</p>
</body>
</html>
Exercises 12, 14, 15, 19, 21 p. 117.
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.