It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Java Forum

having major trouble with work need help urgently pls help

having major trouble with work need help urgently pls help

Postby tiggz1980 on Sun Mar 04, 2007 3:52 pm

could someone please shed some light on this i cant get to grips with java at all.

i need to make the following code convert euros to dollars and vice versa 1 euro = 1.26 dollars and vice versa i cannot make it convert the currency at all i think im going mad please help if you can.

i would imagine its easy i just need pointing in the right direction cant figure out if i need to use an array basically the user needs to select a currency either 0 for Euros or 1 for dollars and then enter a value then convert for relevant currency any help would be greatly appreciated.

<html>
<head> M 150 TMAO3 Question 1
<title>Enter a currency</title>
<script language="JavaScript" >

var currencyType;
currencyType = 0;
var amountEntered;
amountEntered = 0;
var amountConverted;
amountConverted = 0;


currencyType = window.prompt('Please enter the currency) Dollar 1) Euro 0','');
currencyType = parseFloat(currencyType);
while (currencyType <= -1 || currencyType >= 2)
{
currencyType = window.prompt('Please re-enter - currency should be 0 or 1', '');
currencyType = parseFloat(currencyType);

};

amountEntered = window.prompt('Please enter the amount to be converted','');
amountEntered = parseFloat(amountEntered);

if (currencyType = 1)
amountCoverted = 1 * 12.27;

document.write('<BR>' + amountEntered + ' of type ' + currencyType + ' is ... ' + amountConverted + ' <BR> ')

</script>

</head>

<body>
</body>

</html>
tiggz1980
 
Posts: 5
Joined: Fri Mar 02, 2007 12:50 pm
Location: Sheffield, UK

Who is online

Users browsing this forum: No registered users and 2 guests