$30
Assignment 7: JavaScript Conversions
Objectives
• Create websites that take in input via prompt and put that information back on the
screen in various ways.
Instructions
Part 0: The Setup.
Create a folder on your hard disk named lastname_firstname_assignmentNo. You must
replace “No” with the assignment number. Save all the files from this assignment in this
folder. There are several parts to this assignment. Each piece should go inside its subfolder,
starting with part 1. For example, part 1 needs to be in a subfolder named “q1”. Part 2 will
go in “q2” and so forth.
Each question in this assignment requires you to write a website that behaves like an
application. The style for each page will be the same, but the HTML and JavaScript will be
different. The focus of this assignment isn’t CSS. You can use the same CSS code you wrote
from a previous project. However, each page must have a style, and bland websites won’t
work. Also important: students should have different CSS styles.
Each page should have the following components:
• A header section in which you announce the name of your application.
• A main which contains your application.
• A footer in which you present your name and the copyright year. This requirement
should be the same for every question.
These specifications are detailed enough for you to complete each question. However,
you’ll need to use your best judgment on how to code many of the details. To do that, write
the code in the way you think is best, based on the skills presented in the materials. For
example, any time I refer to the title of a page, that should include the title bar and the
content of the header section.
Question 1. 30 points.
Convert miles to kilometers.
Title this page “(Your name)’s Miles to Kilometers Tool”. The program should ask the user
for a distance in miles via an input text field. The user will then click a button labeled
“Convert to Kilometres”. The program will then display the same distance to the screen
converted to kilometers. The application should not use a prompt or alert.
The formula for converting a distance in miles to kilometers is as follows:
K = M * 1.61
Once you get your program written, be sure to check a few examples:
• 1 mile is 1.61 kilometers.
• 10 miles is 16.1 kilometers.
Question 2. 30 points.
Convert feet and inches to just inches.
This program should be titled “(Your name)’s Feet to Inches Converter.” If you are 5 foot 7
inches tall, then how tall are you in inches? There are 12 inches per foot, so you multiply
the number of feet by 12 and add the remaining inches.
Your program should take two inputs (one for feet and the other for inches). You then
convert feet to inches using the following forumla.
total_inches = feet * 12 + inches
Once you get your program written, check some examples.
• 5 foot is 60 inches.
• 5 foot, 7 inches is 67 total inches.
• 6 foot is 72 inches.
In this program, the number of inches supplied by the user will always be a value from 0 to
11.
Question 3. 40 points.
Convert Fahrenheit temperature to Celsius.
This program should be titled “(Your name)’s Fahrenheit to Celsius Tool”. The program
should ask the user for a temperature in degrees Fahrenheit via an input text field. The
user will then click a button labeled “Convert to Celsius”. The program will then display the
exact temperature converted to Celsius. The application should not use a prompt or alert.
The formula for converting a temperature from Fahrenheit to Celsius is as follows:
C = (F - 32) * 5 / 9
Once you get your program written, be sure to check a few examples:
• 32F is 0C
• 212F is 100C
• -40F is -40C
• A nice day is 70F, which is roughly 21.1C.
Turn it in
• I will deduct 20 points for every error and 2 points for every warning when validating
your files.
• Important: Part of web design is that your websites must be readable. I will deduct
points if anything on your page needs to be 100% readable. For example, if there is
text on a background and the background makes the text unreadable, I will deduct
points. If an image obstructs text flow, I will deduct points. I will deduct points if
anything about your page makes it difficult to read the content. If something about the
interface (either input prompts or output) needs to be evident to someone running
your code, I will deduct points.
• There are several critical parts of this assignment that (if missing) will automatically
fail the project:
– The page titles don’t contain your name.
– You must put your name in the document comments for the first HTML file.
• Zip up your folder containing your HTML, CSS, and image files (if applicable) into a
single ZIP file and upload it.