Solved

sum of 5 number using Java script

Posted on 2009-05-19
6
359 Views
Last Modified: 2013-11-05
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
Comment
Question by:miziri
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:satheeshm
ID: 24421181
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24421192
Homework, much?
0
 

Author Comment

by:miziri
ID: 24428728
Hi satheeshm:,
I want all value enter on one prompt only:
var i1 = prompt ("Enter Input Value 1 ?","23427");

thanks
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24428807
If this is homework, please do some of your own investigation.
You want the String split function to split the result
0
 

Author Comment

by:miziri
ID: 24429297
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
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 50 total points
ID: 24429330
Not at all.
Download firefox 3 and open the error console

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

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question