User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,607 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,277 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

currency convertor

Join Date: Dec 2004
Location: Washington DC
Posts: 10
Reputation: Javaknight is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
Javaknight's Avatar
Javaknight Javaknight is offline Offline
Newbie Poster

Solution Re: currency convertor

  #5  
Jan 27th, 2005
Originally Posted by mr woo
I'm close, but can't see the error.......any idea's ??

Boy do I know how you feel :!: You were very close! Remember this about Javascript code: the '+' operator acts as both an agent to add numbers and concatenate strings. The latter, concatenation of strings, is what was happening in your code. Notice the two changes that I made to make it work:

/* Program to read in a known number of data items and store them in an array */

var paymentArray = new Array (4);
var total = new Number;

document.write('Array program to display a customers four quarterly bills to an Electricity company & show the total due');

total = 0

for (var quarter = 0; quarter < paymentArray.length; quarter = quarter + 1)
{
paymentArray[quarter] = window.prompt('Enter payment value','')

}; 
document.write('<BR>' + '<BR>');
document.write('Confirmation of amounts payable' + '<BR>' + '<BR>');


for (var quarter = 0; quarter < paymentArray.length; quarter = quarter + 1)
{
document.write(paymentArray[quarter] + '<BR>')

total = total + Number(paymentArray[quarter])
total = parseFloat(total) 
}
document.write('total amount paid is ' + total + '<br>')

You are definitely well on your way.
Reply With Quote  
All times are GMT -4. The time now is 12:31 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC