<body class="hw">
<div class="container">
<h1>CSCI E-3 Unit 2 Project: Part A</h1>
<p class="whatlearn">This is worth half of the total point value for the
Unit 2 Project. There will be a Unit 2 Project: Part B as well, released in
two weeks. Both Part A and Part B are due on the same date, the
night before Unit 3 begins. We will cover the material required to do
this assignment over the coming weeks, well in advance of when it is
due. </p>
<h3 class="whatlearn">What you're learning:</h3>
<p>How to handle the most basic information in a computer program: numbers
and strings, arrays, and conditionals.<br>
</p>
<ol>
<li>Math: Basic mathematical calculations underlie nearly everything
that you'll do with a computer program: counting photos to layout on
a page, calculating prices in a shopping cart, positioning a ball on a
game screen, or figuring the length of the bar on a graph. <br>
</li>
<li>String Handling: manipulating text</li>
<li>Arrays</li>
<li>Conditionals, looping, and functions are some of the most basic
structures in computer programming. These also underlie just about
everything you'll do in a program. </li>
</ol>
<h3>What you need to do:</h3>
<ol>
<ol>
<li>Follow the example to create your own mathematical converter (5 points)</li>
<li>Place an X in an automatically-chosen random location within a box
(5 points)</li>
<li>Use indexOf() and substr() or slice() to divide your name into two
strings—firstname and lastname (10 points)</li>
<li>Provide a feature in this page that counts the words input into
the input box below (15 points)</li>
<li>Write a function that will calculate the sum of the first 12 even
Fibonacci numbers (20 points)</li>
...
/* CSCI E-3 Introduction to Web Programming Using Javascript
* Spring 2014
*
* Homework Unit #2
*
*
*/
/********************************************************************
*
* First problem: temperature conversion
*
* If the values entered by the user aren't numbers (or convertible to numbers),
* return nothing (or, more specifically, leave the output field blank)
*
********************************************************************/
var convertCtoF = document.getElementById("degC");
convertCtoF.onchange = function(){ //onchange means that every time the value in the input box changes, this function will run
var degreesC = document.getElementById("degC").value; // this is the value from the form field
// your calculations go here. You'll start with the variable degreesC, convert it to Fahrenheit
// and place the result in the variable 'degreesF'
var degreesF = "you haven't written this code yet"; // you will set this to the results of your conversion
var degreesF = (degreesC - 32) * (5/9);
// now we write the result to the page
document.getElementById("degFOut").innerHTML = degreesF;
}
var convertFtoC = document.getElementById("degF");
convertFtoC.onchange = function(){ //onchange means that every time the value in the input box changes, this function will run
var degreesF = document.getElementById("degF").value; // this is the value from the form field
// your calculations go here. You'll start with the variable degreesF, convert it to Celsius
// and place the result in the variable 'degreesC'
var degreesC = "you haven't written this code yet"; // you will set this to the results of your conversion
var degreesC = (degreesF * (9/5)) + 32;
console.log(degreesC)
// now we write the result to...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.