Assignmen 1

Practice Set

by Angela Baruth

HTML

<body onLoad="ontop(), window.resizeTo(280,312)">

<p align="center">Javascript-Calculator - Assignment 1
<p>
<form name="calculator" action="" onSubmit="result();return false;">
<table border="1" cellpadding="8" cellspacing="0" align="center">
<tr>
<td bgcolor="#eeeeee">
<input type="text" name="Display" align="right" class="display"></td>
</tr><tr>
<td bgcolor="#dddddd">
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td><input type="button" width="60" class="button" value=" 7 " onClick="edit('7')"></td>
<td><input type="button" width="60" class="button" value=" 8 " onClick="edit('8')"></td>
<td><input type="button" width="60" class="button" value=" 9 " onClick="edit('9')"></td>
<td><input type="button" width="60" class="button" value=" + " onClick="edit('+')"></td>
</tr>
<tr>
<td><input type="button" width="60" class="button" value=" 4 " onClick="edit('4')"></td>
<td><input type="button" width="60" class="button" value=" 5 " onClick="edit('5')"></td>
<td><input type="button" width="60" class="button" value=" 6 " onClick="edit('6')"></td>
<td><input type="button" width="60" class="button" value=" - " onClick="edit('-')"></td>
</tr>
<tr>
<td><input type="button" width="60" class="button" value=" 1 " onClick="edit('1')"></td>
<td><input type="button" width="60" class="button" value=" 2 " onClick="edit('2')"></td>
<td><input type="button" width="60" class="button" value=" 3 " onClick="edit('3')"></td>
<td><input type="button" width="60" class="button" value=" * " onClick="edit('*')"></td>
</tr>
<tr>
<td><input type="button" width="60" class="button" value=" = " onClick="result()"></td>
<td><input type="button" width="60" class="button" value=" 0 " onClick="edit('0')"></td>
<td><input type="button" width="60" class="button" value=" / " onClick="edit('/')"></td>
</tr>
<tr>
<td><input type="button" width="60" class="button" value=" sqrt " onClick="Specialfunction('sqrt')"></td>
<td><input type="button" width="60" class="button" value=" x² "...

CSS

/* integrate here CSS code from Html code
 */

JavaScript

/* CSCI E-3 Introduction to Web Programming Using Javascript
 * Fall 2016
 *
 * 1. Assignments Practice Set 
 *
 */
"use strict";

/* function with result
 */
function Check(result)
{

/* variable with number and maths*/
// Insert your code here

var valid ="";

/* loops through a block of code a number of times

/* Statement 1 sets a variable before the loop starts (var i = 0).*/

/* Statement 2 defines the condition for the loop to run (i must be less than result).*/

/* Statement 3 increases a value (i++) each time the code block in the loop has been executed.*/

// Insert your code here
for ()

/* The charAt() method returns the specified character from a string.
*An integer between 0 and 1-less-than the length of the string. If no index is provided, charAt() will use 0. A string representing the character at the specified index; empty string if index is out of range. Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character in a string called stringName is stringName.length - 1. If the index you supply is out of range, JavaScript returns an empty string. If no index is provided to .charAt(), 0 will be used as default. */

/* The indexOf() method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found.*/

// Insert your code here - definite here indexOf

if (valid.indexOf() return false;
return true;
}


/* function put out result*/
// Insert your code here  with window.document.calculator.Display.value

function result() {
var x = 0;
if (Check(window.document.calculator.Display.value))
x = eval(window.document.calculator.Display.value);
// Definite your code here
}


/* function edit character */

function edit(character) {
window.document.calculator.Display.value =
// Definite your code here 
}

/* function special math  Math.sqrt(x);*/

function Specialfunction(Funktion)...