Google Search

Friday, October 7, 2011

Write Java Script that inputs three integers from the user and outputs their sum, average, largest.


AIM
Write Java Script that inputs three integers from the user and outputs their sum, average, largest. Use alert dialog box to display results.PROGRAM
--------------------------------------------------------------------------
<html> <head> <title> MAX </title>
<script language="javascript">
var a,b,c,n1,n2,n3,m1,m2,sum,avg;
a=prompt("enter 1st no="," ");
b=prompt("enter 2nd no="," ");
c=prompt("enter 3rd no="," ");
n1=parseInt(a);
n2=parseInt(b);
n3=parseInt(c);
sum=n1+n2+n3;
avg=sum/3;
m1=Math.max(n1,n2);
m2=Math.max(n3,m1);
alert("the sum is= "+sum);
alert("the avg is= "+m2);
alert("the max no is "+m2);
</script> </head></html>

0 comments:

Post a Comment