per
12-14-2003, 04:17 AM
Hi there,
i have got this code:
<HTML>
<HEAD>
<TITLE>Web Page containing JavaScript</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function largest(no1, no2, no3){
var biggest
no1=parseFloat(no1)
no2=parseFloat(no2)
no3=parseFloat(no3)
biggest=no1
if (no2>biggest) {
biggest=no2
}
if (no3>biggest) {
biggest=no3
}
return biggest
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<H1><FONT COLOR="BLUE">A Function To Calculate The Largest Value</FONT></H1>
<SCRIPT>
<!--
var number1, number2, number3, max
number1=window.prompt("What is your first number","?")
number2=window.prompt("What is your second number","?")
number3=window.prompt("What is your third number","?")
max=largest(number1, number2, number3)
window.alert("The largest number entered was " + max)
//-->
</SCRIPT>
</BODY>
</HTML>
and now i was wanting to configure it a bit with these details:
Add a second function to calculate the average of the numbers entered, and a third to calculate the minimum value.
Use these functions, so that after alerting the user of the largest number entered, it also alerts him/ her of the average and smallest values as well.
thanks for any help
i have got this code:
<HTML>
<HEAD>
<TITLE>Web Page containing JavaScript</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function largest(no1, no2, no3){
var biggest
no1=parseFloat(no1)
no2=parseFloat(no2)
no3=parseFloat(no3)
biggest=no1
if (no2>biggest) {
biggest=no2
}
if (no3>biggest) {
biggest=no3
}
return biggest
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<H1><FONT COLOR="BLUE">A Function To Calculate The Largest Value</FONT></H1>
<SCRIPT>
<!--
var number1, number2, number3, max
number1=window.prompt("What is your first number","?")
number2=window.prompt("What is your second number","?")
number3=window.prompt("What is your third number","?")
max=largest(number1, number2, number3)
window.alert("The largest number entered was " + max)
//-->
</SCRIPT>
</BODY>
</HTML>
and now i was wanting to configure it a bit with these details:
Add a second function to calculate the average of the numbers entered, and a third to calculate the minimum value.
Use these functions, so that after alerting the user of the largest number entered, it also alerts him/ her of the average and smallest values as well.
thanks for any help