Temp Conversion Program...Help please

N

nyy

Hello everybody on this group. I have this program that is supposed to
display a temp. conversion from fahrenheit to celsius, can anybody
kindly can tell me what is wrong? Thanks.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Temperature Conversion</title>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
var fahrenheit = new Array();
var celcius = 0;
for (var i = 0; i <= 100; ++i) {
fahrenheit = i;
}
for (var j=0, j<100, ++j) {
celcius = (fahrenheit - 32) * .55
document.write(fahrenheit + " degrees Fahrenheit is equal to "
+ celcius + celsius.<br />);
}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
</body>
</html>
 
P

pipe

for (var i = 0; i <= 100; ++i) {

for (var j=0, j<100, ++j) {

notice the <= in the first line and the < in the second.

notice also that u dont need the array.

and also that you are using document.write in the head section, and not
in the body section.
 
R

RobG

nyy said:
Hello everybody on this group. I have this program that is supposed to
display a temp. conversion from fahrenheit to celsius, can anybody
kindly can tell me what is wrong? Thanks.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Temperature Conversion</title>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

Forget using HTML comments inside script elements, particularly if your
browser is interpreting this as genuine XHTML - in which case
document.write may cause you some heartache too.

But never mind...
var fahrenheit = new Array();

This array is not required.
var celcius = 0;

This variable is not needed. If the intention is to write conversions
for 0 to 100 degrees Celsius to Fahrenheit, then the following:

for (var i=0; i <= 100; ++i) {
document.write( i + ' degrees Celcius is equal to '
+ (Math.round(i*9/5 + 32))
+ ' degrees Fahrenheit.<br />'
);
}

should do the trick, unless the point of the exercise was to use an array?

[...]
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Wed, 21 Sep 2005 08:05:57, seen in nyy
celcius = (fahrenheit - 32) * .55


Your ".55" should be written "0.55". Javascript will understand either,
bur relying on a half-bare decimal dot is liable to lead to human error.
See, if you have access, IUPAP-25 / SUNAMCO 87-1.

The conversion factor is in fact not 0.55 but bigger.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Please Help? 0
Help with code! PLEASE! 1
Script Help 6
Help with code 0
Help with my responsive home page 2
Help :( 3
Need help again please 19
can anyone help me with my javascript program? 1

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top