第二章第十题(科学:计算能量)(Science: calculating energy)

第二章第十题(科学:计算能量)(Science: calculating energy)

  • 2.10(科学:计算能量)编写程序,计算将水从初始温度加热到最终温度所需的能量。程序应该提示用户输入水的重量(以千克为单位),以及水的初始温度和最终温度。
    计算能量的公式是:Q = M × (最终温度 - 初始温度) × 4184

    这里的M是以千克为单位的水的重量,温度以摄氏度为单位,而能量Q以焦耳为单位。
    下面是一个运行示例:
    Enter the amount of water in kilograms : 55.5
    Enter the initial temperature : 3.5
    Enter the final temperature : 10.5
    The energy needed is 1625484

    2.10(Science: calculating energy) Write a program that calculates the energy needed to heat water from an initial temperature to a final temperature. Your program should prompt the user to enter the amount of water in kilograms and the initial and final temperatures of the water.
    The formula to compute the energy is Q = M × (finalTemperature – initialTemperature) × 4184

    where M is the weight of water in kilograms, initial and final temperatures are in degrees Celsius, and energy Q is measured in joules.
    Here is a sample run:
    Enter the amount of water in kilograms : 55.5
    Enter the initial temperature : 3.5
    Enter the final temperature : 10.5
    The energy needed is 1625484

  • 参考代码:

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ASP函数 IsNull()   FUNCTION: 判断一对象是否为空,返回布尔值.   SYNTAX: IsNull(expression)   ARGUMENTS:   EXAMPLE: $#@60;%       Dim i       response.write IsNull(i)       %>   RESULT: False IsNumeric()   FUNCTION: 判断一对象是否为数字,返回布尔值.   SYNTAX: IsNumeric(expression)   ARGUMENTS:   EXAMPLE: $#@60;%        i = "345"        response.write IsNumeric(i)       %>   RESULT: True 就算数字加了引号,ASP还是认为它是数字。 IsObject()   FUNCTION: 判断一对象是否为对象,返回布尔值.   SYNTAX: IsObject(expression)   ARGUMENTS:   EXAMPLE: $#@60;%        Set con = Server.CreateObject("ADODB.Connection")        response.write IsObject(con)       %>   RESULT: True LBound()   FUNCTION: 返回指定数组维的最小可用下标.   SYNTAX: Lbound(arrayname [, dimension])   ARGUMENTS: ; dimension 指明要返回哪一维下界的整数。使用 1 表示第一维,2 表示第二维,以此类推。如果省略          dimension 参数,默认值为 1.   EXAMPLE: $#@60;%        i = Array("Monday","Tuesday","Wednesday")        response.write LBound(i)        %>   RESULT: 0 LCase()   FUNCTION: 返回字符串的小写形式   SYNTAX: Lcase(string)   ARGUMENTS: string is any valid string expression.   EXAMPLE: $#@60;%        strTest = "This is a test!"        response.write LCase(strTest)       %>   RESULT: this is a test! Left() <   FUNCTION: 返回字符串左边第length个字符以前的字符(含第length个字符).   SYNTAX: Left(string, length)   ARGUMENTS:   EXAMPLE: $#@60;%       strTest = "This is a test!"       response.write Left(strTest, 3)       %>   RESULT: Thi Len()   FUNCTION: 返回字符串的长度.   SYNTAX: Len(string | varName)   ARGUMENTS:   EXAMPLE: $#@60;%        strTest = "This is a test!"        response.write Len(strTest)       %>   RESULT: 15 LTrim()   FUNCTION: 去掉字符串左边的空格.   SYNTAX: LTrim(string)   ARGUMENTS:   EXAMPLE: $#@60;%       strTest = " This is a test!"       response.write LTrim(strTest)       %>   RESULT: This is a test! Mid()   FUNCTION: 返回特定长度的字符串(从start开始,长度为length).   SYNTAX: Mid(string, start [, length])   ARGUMENTS:   EXAMPLE: $#@60;%        strTest = "This is a test! Today is Monday."        response.write Mid(strTest, 17, 5)       %>   RESULT: Today
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值