timewarp

Apr 17th, 2013, 06:13 PM

Hi,

Trying to create a multiple condition while loop this is what i have:

<html>

<head>

<title> fuel </title>

</head>

<body>

<script>

var capacity = parseInt(prompt("Enter amount of gallons:",100));

var mpg = parseInt(prompt("Enter mpg:",100));

var price = parseFloat(prompt("Enter price of a gallon of petrol:"));

while (((capacity <=6 && capacity <=20) mpg <=20 && mpg <=75) price < 3.20 && 4.20) {

var eco = capacity * mpg;

var cost = (100 / mpg * price);

document.write("The car will travel: "+ eco + " : " + "the cost of travel is : " + cost);

mpg = 0;

price = 0;

capacity = 0;

}

</script>

</body>

</html>

not sure where ive gone wrong as i haven't done one before,

the conditions are that: gallons must be between 6 and 20

efficiency must be between 20 and 75

price must be between £3.20 and £4.20

Any help would be appreciated

thanks

Trying to create a multiple condition while loop this is what i have:

<html>

<head>

<title> fuel </title>

</head>

<body>

<script>

var capacity = parseInt(prompt("Enter amount of gallons:",100));

var mpg = parseInt(prompt("Enter mpg:",100));

var price = parseFloat(prompt("Enter price of a gallon of petrol:"));

while (((capacity <=6 && capacity <=20) mpg <=20 && mpg <=75) price < 3.20 && 4.20) {

var eco = capacity * mpg;

var cost = (100 / mpg * price);

document.write("The car will travel: "+ eco + " : " + "the cost of travel is : " + cost);

mpg = 0;

price = 0;

capacity = 0;

}

</script>

</body>

</html>

not sure where ive gone wrong as i haven't done one before,

the conditions are that: gallons must be between 6 and 20

efficiency must be between 20 and 75

price must be between £3.20 and £4.20

Any help would be appreciated

thanks