473,800 Members | 2,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>Temperat ure 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 2160

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.c om/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>Temperat ure 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******** *************@f 14g2000cwb.goog legroups.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>Temperat ure 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************ *********@f14g2 000cwb.googlegr oups.com>,
dated Wed, 21 Sep 2005 08:05:57, seen in news:comp.lang. javascript, nyy
<je****@yahoo.c om> 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.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.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
2104
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 carrige return and feed line my program will prompt the user to enter a file to open and then prompts for a destination file to save the new formatted file. I am having few problems that i have been trying to solve for few hours here is the code I...
5
3363
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 printer using a RawPrinterHelper class that i found I believe in the msdn. the class works wonderfully when I send stright text data (in the correctly formated string that the sato printer requires.) but when i go to send a image nothing is...
0
1663
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 the temp files by one of two techniques: A. I open the Back End and copy one file and paste it with a name with the end temp..and is "Units Temp".
31
6652
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 variable becomes 364 and the other one becomes 365. Does anyone have any insight to what the problem is? Thanks in advance. Bjørn
14
12747
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 runs fine if the user enters a number, but if the user enters a letter it loops. I have been working on this for 3 hours now, trying different things
3
7286
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. Now i want this temp file to be destroyed if this application is closed / crashes. Is this possible? Please help. Thanks in advance, Harsh
8
1898
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 to extract data from a database using ODBC. A search on the internet led me to the page at http://forums.asp.net/27667/ShowPost.aspx that contained a functional example in VB.NET. This worked on my computer. Hereunder is a snippet
0
1388
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 to implement 'operator()' s.t. I can treat parts of a vector in the same way as a normal vector: if v.foo(...) works, so should v(rng).foo(...), where rng is a range object. This should work even if 'foo' is a non-const method. I do this by...
1
1210
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 conversion(converting)... Guys, please hep me. your the only one could help me guys!!! can you write a C++/C program code for conversion below: meter to kilometer
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10504
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10274
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10251
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.