注册 登录
查看: 2118|回复: 0
打印 上一主题 下一主题

英文作业:编写一个程序,提示用户输入温度和风速,程序然后显示风寒指数

[复制链接]

该用户从未签到

3524

主题

3538

帖子

67万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
673178
QQ
跳转到指定楼层
楼主
发表于 2018-9-24 08:11:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Assignment #2
Goals:
Ø  Thisassignment gives students more experience in:
·        Problem Solving
·        Writing Java programs
·        Writing Algorithms,using pseudo code
Problem Description
How cold is it outside? Thetemperature alone is not enough to provide the answer. Other factors includingwind speed, relative humidity, and sunshine play important roles in determiningcoldness outside.
In 2001, the NationalWeather Service implemented the new wind-chill index to measure the coldnessusing temperature and wind speed.
The formula is given asfollows:
  Twc = 13.112 + 0.6215 Ta -11.37 V0.16 + 0.3965 Ta V0.16
Where
·        Ta is the ambientair temperature in Celsius degree,
·        V is the wind speedin kilometers per hour,
·        Twc is the wind-chill index.
The formula can be usedonly for:
·        wind speeds between 0 and 100 km/h, and
·        temperatures between -50 and 5°C
Requirements
Write a program thatprompts the user to enter a temperature and a wind speed, the program then displaysthe wind-chill index. Use Math.pow(a, b) to compute V0.16.
Here is a sample program run:
  This program calculates the wind-chill index.
Enter the temperaturein Celsius: 0
Enter the wind speed kilometersper hour: 20
The wind chill indexis -5
·        Your programshould display the wind chill index as an integer number.
·        Your programsshould also display an appropriate error message and terminate if the userenters invalid input. For example:
Ø  If the temperature entered is not between -50oC and 5oC.
Ø  If the wind speed entered is not between 0 and 100 km/h.
Make a folder containingyour source code, and external document file, zip the folder and submit the zipfile to BrightSpace.
Marking Scheme
[4 marks] Presentation and Style: Readability, descriptiveidentifier,
                 indentation, bracket placement
[8 marks] Correctness: Program works without bugs
[4 marks] Error checking: Appropriate error message to the user when
                 invalid data is entered.
[4 marks] Documentation: External and Internal


目标:
这个作业给学生更多的经验:
解决问题
编写Java程序
使用伪代码编写算法
问题描述
外面有多冷?单靠温度是不够的。风速、相对湿度和日照等因素对室外寒冷的影响起着重要的作用。
2001年,国家气象局实施了新的风冷指数,利用温度和风速测量寒冷。
公式如下:
TWC=13.112+0.6215 Ta=1137 V0.16+ 0.3965 Ta V0.16
在哪里?
TA是摄氏摄氏度的环境空气温度,
v是每小时公里的风速,
TWC是风寒指数。
公式只能用于:
风速在0至100公里/小时之间,以及
温度在50℃和5℃之间
要求
编写一个程序,提示用户输入温度和风速,程序然后显示风寒指数。使用数学.PoW(a,b)来计算v0.16。
这里有一个示例程序运行:
这个程序计算风寒指数。
进入摄氏温度:0
输入风速公里每小时:20
寒风指数为-5
你的程序应该把风寒指数作为整数来显示。
您的程序还应该显示一个适当的错误消息,如果用户输入无效的输入,则终止。例如:
如果进入的温度不在-50℃和5℃之间。
如果风速输入不在0至100公里/小时之间。
制作一个包含源代码和外部文档文件的文件夹,压缩文件夹并将zip文件提交给BrightSpace。
标记方案
[ 4分]介绍和风格:可读性,描述性标识符,
压痕,托槽放置
[ 8个标记]正确性:程序没有bug
[ 4个标记]错误检查:何时向用户发出适当的错误消息
输入无效数据。
文献〔4分〕:外部与内部
代码:
import java.util.Scanner;


public class Test {

        /**
         * @param args
         */
        public static void main(String[] args) {
                // TODO Auto-generated method stub
                Scanner input=new Scanner(System.in);
                System.out.println("Enter the wind speeds between 0 and 100 km/h, and temperatures between -50 and 5°C");
                System.out.print("Enter the temperature in Celsius:");
                double ta=input.nextDouble();
               
                System.out.print("Enter the wind speed kilometers per hour:");
                double v=input.nextDouble();
               
                double twc=13.112 + 0.6215* ta -11.37 *Math.pow(v, 0.16) + 0.3965 *ta* Math.pow(v, 0.16);
       
                System.out.println("The wind chill index is "+(int)twc);
        }


}




分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
java无忧网(http://www.javawyw.com),专业提供Java大作业,小作业,课程设计,毕业设计源码,答辩辅导,作业排错,bug修复,专业解答,远程部署运行项目等服务
本网站所有源码,保证能运行!
QQ:1399491757
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回列表 返回顶部