[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

sum of 5 number using Java script

Hi,
I want java scriopt program to enter 5 value
and print in screen again and with sum of this 5 munber


like this will appear
2
3
4
2
7
sum=18
0
miziri
Asked:
miziri
  • 3
  • 2
1 Solution
 
satheeshmCommented:
Hi,

Try this code

<script type="text/javascript">
<!--

var i1 = prompt ("Enter Input Value 1 ?","2");
var i2 = prompt ("Enter Input Value 2 ?","3");
var i3 = prompt ("Enter Input Value 3 ?","4");
var i4 = prompt ("Enter Input Value 4 ?","2");
var i5 = prompt ("Enter Input Value 5 ?","7");

alert ("Sum of Input Values is : " + (parseInt(i1)+parseInt(i2)+parseInt(i3)+parseInt(i4)+parseInt(i5)));
document.writeln("Sum of Input Values is : " + (parseInt(i1)+parseInt(i2)+parseInt(i3)+parseInt(i4)+parseInt(i5)));

// -->
</script>
0
 
Michel PlungjanIT ExpertCommented:
Homework, much?
0
 
miziriAuthor Commented:
Hi satheeshm:,
I want all value enter on one prompt only:
var i1 = prompt ("Enter Input Value 1 ?","23427");

thanks
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Michel PlungjanIT ExpertCommented:
If this is homework, please do some of your own investigation.
You want the String split function to split the result
0
 
miziriAuthor Commented:
Hi mplungjan:
Friend do have specail link which i can find many example
real difficult with java with notepad not complier to know error location\

thx
0
 
Michel PlungjanIT ExpertCommented:
Not at all.
Download firefox 3 and open the error console

http://w3schools.com/js/default.asp
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now