温度转换器 [英] Temperature Converter

查看:81
本文介绍了温度转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全坚持使用这个。

我必须创建一个温度转换计算器,将结果温度四舍五入到最接近的整数&反之亦然。结果必须显示在窗口警报中。给定的公式是(Fahrenheit_temp - 32)* .55

我唯一的提示/线索是使用

var tempInCelcius =(document.Converter.fahrenheit.value - 32)* .55;

var tempInFahrenheit =(document.Converter.celcius.value * 1.8)+ 32


我试过,删除,试过和再次删除。我很沮丧,感到自杀,我只是没有理解这个概念。


请帮助!


< html>

< head>

< title>转换温度< / title>


< script language =" JavaScript">


<! - 隐藏旧浏览器

函数tempConv(){

var TempInCelcius = document.Converter.fahrenheit .value - 32)* .55;

var TempInFahrenheit = document.Converter.celcius.value * 1.8)+ 32;


????? ? - 我无法得到正确的计算结果????????


// - >

< / script>


< / head>

< body>


< h1>转换温度< / h1> ;

< form name = data>

< p>< strong>以华氏温度输入温度< / strong>< / p>

< input type =" text"名称= QUOT;摄氏度"大小= QUOT; 10" align =" left">

< input type =" Button"对齐= QUOT;左" value ="转换为Celcius" onClick = tempConv()>

< br>

< p>< strong>以Celcius输入温度< / strong>< / p>

< input type =" text"名称= QUOT; fahrenheit_in"大小= QUOT; 10" align =" left">

< input type =" Button"对齐= QUOT;左" value ="转换为Fahrenheit" onClick =" tempConv()">


< / body>

< / html>

I am absolutely stuck with this one.
I have to create a temperature conversion calculator that rounds the resulting temperature to the nearest whole number & vice versa. The result must be displayed in a window alert. The given formula is (Fahrenheit_temp - 32) * .55
The only tip/clue I have is to use
var tempInCelcius = (document.Converter.fahrenheit.value - 32) * .55;
var tempInFahrenheit = (document.Converter.celcius.value * 1.8) + 32

I have tried, deleted, tried and deleted again. I am so frustrated and feeling suicidal that I am just not grasping the concept.

PLEASE HELP!

<html>
<head>
<title>Convert Temperature</title>

<script language="JavaScript">

<!--Hide from old browsers
function tempConv() {
var TempInCelcius = document.Converter.fahrenheit.value - 32) * .55;
var TempInFahrenheit = document.Converter.celcius.value * 1.8) + 32;

?????? - I cannot get the calc right????????


//-->
</script>

</head>
<body>

<h1>Convert Temperature</h1>
<form name=data>
<p><strong>Enter the temperature in Fahrenheit</strong></p>
<input type="text" name="Celcius" size="10" align="left">
<input type="Button" align="left" value="Convert to Celcius" onClick=tempConv()>
<br>
<p><strong>Enter the temperature in Celcius</strong></p>
<input type="text" name="fahrenheit_in" size="10" align="left">
<input type="Button" align="left" value="Convert to Fahrenheit" onClick="tempConv()">


</body>
</html>

推荐答案

使用Math对象。它有圆形,地板和其他可以使用的方法。
Use Math object. It has round, floor and maybe other methods you can use.


你有一些语法错误。请查看以下代码以进行一些更正。如果您在完成项目时遇到更多问题,我将非常乐意为您提供帮助。

You had a few syntax errors. Look at the following code for some corrections. If you have more questions while finishing your project, I''ll be glad to help.

展开 | 选择 | Wrap | 行号



您有一些语法错误。请查看以下代码以进行一些更正。如果您在完成项目时遇到更多问题,我将非常乐意为您提供帮助。

You had a few syntax errors. Look at the following code for some corrections. If you have more questions while finishing your project, I''ll be glad to help.

展开 | 选择 | Wrap | 行号


这篇关于温度转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆