0

Please can somebody help me please i am to provide a table of values showing conversion from pounds to dollars, I have to have a table howing different values i.e £150. into dollars, £200. to dollars etc. I have treid this but it doesn't work, please could you give me some idea where i am going wrong. :o

thanx for your help
laguna915

Attachments
<HTML>
<HEAD>
<TITLE>Currency Converter B</TITLE>
<SCRIPT>

var amountInPounds, amountInDollars, dollarRate;
document.write('Currency Converter Application B' + '<BR>');
dollarRate = 1.78;
amountInPounds = parseFloat(amountInPounds);
window.prompt('Please enter amount in pounds sterling, 10 to 120','');
while (amountInPounds != 10)
{
document.write('Pounds' + 'Dollars' + '<BR><BR>');
dollarRate = dollarRate * amountInPounds;
window.prompt('Please enter amount in pounds sterling, 10 to 120','');
amountInPounds = parseFloat(amountInPounds)

};
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
3
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by DanceInstructor
0

first lets look at your code:

<HTML>
<HEAD>
<TITLE>Currency Converter B</TITLE>
<SCRIPT>
var amountInPounds, amountInDollars, dollarRate;
document.write('Currency Converter Application B' + '<BR>');
dollarRate = 1.78;
amountInPounds = parseFloat(amountInPounds);
window.prompt('Please enter amount in pounds sterling, 10 to 120','');
while (amountInPounds != 10)
{
document.write('Pounds' + 'Dollars' + '<BR><BR>');
dollarRate = dollarRate * amountInPounds;
window.prompt('Please enter amount in pounds sterling, 10 to 120','');
amountInPounds = parseFloat(amountInPounds)
};
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>

well i think part of your problem is that you told the script that while any value other than 10 to do this, yet you want a value between 10 and 120, you need something more like while (ammountinpounds < 10), so that all values below ten are discounted, and somthing like (i dont know the syntax in js) ammountinpounds >120 so that all values too high will be discounted. also, no where do i see any math to do a conversion...so im a bit lost as too what your code is supposed to do.

0

Does you page have any output at all? If not then try moving the script from the head to inside of the body tags.

[EDIT]BAH! I just realized the origional post is over a month old :([/EDIT]

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.