• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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