<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("degreesInCelsius");
convertCtoF.onchange = function(){
var degreesInCelsius = document.getElementById("degreesInCelsius").value;
var degreesInFahrenheit = "you haven't written this code yet";
var degreesInFahrenheit = (degreesInCelsius - 32) * (5/9);
document.getElementById("degFOut").innerHTML = degreesInFahrenheit;
}
var convertFtoC = document.getElementById("degInFahrenheit");
convertFtoC.onchange = function(){
var degreesInFahrenheit = document.getElementById("degInFahrenheit").value;
var degreesInCelsius = "you haven't written this code yet";
var degreesInCelsius = (degreesInFahrenheit * (9/5)) + 32;
console.log(degreesC)
document.getElementById("degCOut").innerHTML = degreesC;
}
Probelm 2
var putAnXBtn = document.getElementById("putAnXButton");
putAnXBtn.onclick = function(){
// get a reference to the box
var theBox = document.getElementById("putAnX");
// now get the width and height of the box - see the clientWidth and clientHeight documentation at http://docs.webplatform.org/wiki/dom/HTMLElement
var width = theBox.clientWidth;
var height = theBox.clientHeight;
/*
* Now, here's where you do your magic. The xPosition and yPosition should not be set to zero.
*
* Use the Math.random() function to get a number between
...
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.