473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Temp Conversion Program...Help please

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] = i;
}
for (var j=0, j<100, ++j) {
celcius = (fahrenheit[i] - 32) * .55
document.write(fahrenheit[i] + " degrees Fahrenheit is equal to "
+ celcius + celsius.<br />);
}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
</body>
</html>

Sep 21 '05 #1
4 2136

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.

--
[php/javascript/coldfusion/ajax stuff]
http://www.geocities.com/kyoosho/

Sep 21 '05 #2
nyy wrote:
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?

[...]


--
Rob
Sep 21 '05 #3
nyy wrote in message news:11*********************@f14g2000cwb.googlegro ups.com...
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.
Hi nyy, this is King Sapingo, remember me ;-)

I have a few comments:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
why XHTML
<html>
<head>
<title>Temperature Conversion</title>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
as someone else mentioned in another post,
there are no /incompatible browsers/
(in other words, you don't need this,
unless you actually publish it as XML (XHTML)
then you need the <![CDATA[ definition)

anyway, back to your problem:
var fahrenheit = new Array();
var celcius = 0;
for (var i = 0; i <= 100; ++i) {
fahrenheit[i] = i;
}
for (var j=0, j<100, ++j) { ^ ^
for (init ; while;incr)
you also probably mean j<=100
since you said i<=100 earlier

for (var j=0; j<=100; ++j)
celcius = (fahrenheit[i] - 32) * .55 ^ ^
didn't you want j instead of i? and end the line with ";"
(you will be surprised about some of the results "* 0.55" yelds ;-)
document.write(fahrenheit[i] + " degrees Fahrenheit is equal to " ^
the same j instead of i?
+ celcius + celsius.<br />); ^^^^^^^^^^^^^^^
you probably want this in "quotes" }
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
</body>
</html>


HTH
Sep 22 '05 #4
JRS: In article <11*********************@f14g2000cwb.googlegroups. com>,
dated Wed, 21 Sep 2005 08:05:57, seen in news:comp.lang.javascript, nyy
<je****@yahoo.com> posted :
celcius = (fahrenheit[i] - 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.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: kalio80 | last post by:
Hi everyone I am trying to create a file that converts text files from unix to windows and windows to unix I understand the general concept of it as unix uses line feed LF Windows uses CRLF...
5
by: john | last post by:
Here is the short story of what i'm trying to do. I have a 4 sided case labeling printer setting out on one of our production lines. Now then i have a vb.net application that sends data to this...
0
by: John Baker | last post by:
Hi; I am have a db back end situation, and have a problem with temp files. I am attempting to use temp files to manage the modification of a master file, and its not working right. I set up...
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
14
by: Just starting out | last post by:
I am very new to C code and I'm having a lot of trouble with a homework assignment. This program is supposed to take the amount of Euros that the user enters and convert it to US dollars. It...
3
by: Harsh Vardhan Singh | last post by:
hi, i am trying to create a temporary file associated with a particular process. For instance, i have a windows application which will create a temp file as soon as it this program is executed....
8
by: acb | last post by:
Hello, I am a beginner in ASP.NET and C# having programmed in VB (not the .NET flavour) in the past. I am looking for assistance in converting a functional VB.NET aspx page to C#. I am trying...
0
by: mseeger | last post by:
My concrete problem is this (it is a bit special, but there may be other instances of it): I'd like to create a class for vectors (say: Vector), exporting math. methods, say v.foo(...). I'd like...
1
by: earnswellme | last post by:
hello good evening to everyone: Tomorrow is our practical exam (for our final exam) and we will have this final exam, our teacher give us the clue that we will write a program that will used...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.