Hello...I need help with this one. I want to input 2 numbers and display to the screen the following:
The sum (first + second).
The difference (first ?second)
The product (first * second).
The quotient (first / second, second cannot be 0)
The remainder (first / second remainder, second cannot be 0).
The average ((first + second) / 2)
The smaller of the two numbers.
The larger of the two numbers.
This is an example that I have but can't get it to work. I'm lost. Thank You.
<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<html>
<head>
<script language = "JavaScript">
var x = 0;
var y = 0;
function doCalculations()
{
var sum = 0;
var diff = 0;
var prod = 0;
var quot = 0;
var mod = 0;
var avg = 0;
var min = 99999999999999999999999999999999;
var max = -99999999999999999999999999999999;
x = parseInt (prompt ("Enter first # (default 10):", "10"));
if (isNaN (x))
{
window.status = "Non-numeric value entered. Reset to 10";
x = 10;
}
y = parseInt (prompt ("Enter second # (default 3):", "3"));
if (isNaN (y))
{
window.status = "Non-numeric value entered. Reset to 3";
y = 3;
}
} sum = ();
diff = ();
prod = ();
quot = ();
mod = ();
avg = ();
min = ();
max = ();
alert (x + " + " + y + " = " + sum + "\n" +
x + " - " + y + " = " + diff + "\n" +
x + " * " + y + " = " + prod + "\n" +
x + " / " + y + " = " + quot + "\n" +
x + " % " + y + " = " + mod + "\n" +
"Avg of " + x + " and " + y + " is " + avg + "\n" +
"Min of " + x + " and " + y + " is " + min + "\n" +
"Max of " + x + " and " + y + " is " + max + "\n");
}
}
</script>
</head>
<body bgcolor="lightblue">
<form name = "myForm">
<input type = "button" name = "NumButton"
value = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/">http://www.webdeveloper.com/forum/archive/index.php/</a><!-- m -->"Click Here To Enter A Number"
onClick = "doCalculations()">
</form>
</body>
</html>
The sum (first + second).
The difference (first ?second)
The product (first * second).
The quotient (first / second, second cannot be 0)
The remainder (first / second remainder, second cannot be 0).
The average ((first + second) / 2)
The smaller of the two numbers.
The larger of the two numbers.
This is an example that I have but can't get it to work. I'm lost. Thank You.
<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<html>
<head>
<script language = "JavaScript">
var x = 0;
var y = 0;
function doCalculations()
{
var sum = 0;
var diff = 0;
var prod = 0;
var quot = 0;
var mod = 0;
var avg = 0;
var min = 99999999999999999999999999999999;
var max = -99999999999999999999999999999999;
x = parseInt (prompt ("Enter first # (default 10):", "10"));
if (isNaN (x))
{
window.status = "Non-numeric value entered. Reset to 10";
x = 10;
}
y = parseInt (prompt ("Enter second # (default 3):", "3"));
if (isNaN (y))
{
window.status = "Non-numeric value entered. Reset to 3";
y = 3;
}
} sum = ();
diff = ();
prod = ();
quot = ();
mod = ();
avg = ();
min = ();
max = ();
alert (x + " + " + y + " = " + sum + "\n" +
x + " - " + y + " = " + diff + "\n" +
x + " * " + y + " = " + prod + "\n" +
x + " / " + y + " = " + quot + "\n" +
x + " % " + y + " = " + mod + "\n" +
"Avg of " + x + " and " + y + " is " + avg + "\n" +
"Min of " + x + " and " + y + " is " + min + "\n" +
"Max of " + x + " and " + y + " is " + max + "\n");
}
}
</script>
</head>
<body bgcolor="lightblue">
<form name = "myForm">
<input type = "button" name = "NumButton"
value = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/">http://www.webdeveloper.com/forum/archive/index.php/</a><!-- m -->"Click Here To Enter A Number"
onClick = "doCalculations()">
</form>
</body>
</html>