您好,欢迎来到九壹网。
搜索
您的当前位置:首页java语言程序设计基础篇第十版课后答案第二章答案

java语言程序设计基础篇第十版课后答案第二章答案

来源:九壹网
package cn.Testcx;

import java.util.Scanner;

public class lesson2 {

public static void main(String[] args){ @SuppressWarnings(\"resource\") Scanner input =new Scanner(System.in);

System.out.print(\"请输入一个摄氏温度: \"); double Celsius =input.nextDouble(); double Fahrenheit =(9.0/5)*Celsius+32; System.out.println(\"摄氏温度:\"+Celsius+\"度 \"+\"转换成华氏温度为:\"+Fahrenheit+\"度\"); System.out.print(\"请输入圆柱的半径和高: \"); double radius =input.nextDouble(); int higth = input.nextInt(); double areas =radius*radius*Math.PI; double volume =areas*higth; System.out.println(\"圆柱体的面积为:\"+areas); System.out.println(\"圆柱体的体积为:\"+volume); System.out.print(\"输入英尺数:\"); double feet =input.nextDouble(); double meters =feet*0.305; System.out.println(feet+\"英尺转换成米:\"+meters); System.out.print(\"输入一个磅数:\"); double pounds =input.nextDouble(); double kilograms =pounds*0.454;

System.out.println(pounds+\"磅转换成千克为:\"+kilograms); System.out.println(\"输入分钟数:\"); long minutes =input.nextInt(); long years =minutes/(24*60*365);

long days = (minutes%(24*60*365))/(24*60);

System.out.println(minutes+\"分钟\"+\"有\"+years+\"年和\"+days+\"天\"); long totalCurrentTimeMillis =System.currentTimeMillis(); long totalSeconds =totalCurrentTimeMillis/1000; long currentSeconds =totalSeconds%60; long totalMinutes =totalSeconds/60; long currentMinutes =(totalSeconds%(60*60))/60; long currenthours =(totalMinutes/60)%24; System.out.print(\"输入时区偏移量:\"); byte zoneOffset = input.nextByte(); long currentHour =(currenthours+(zoneOffset*1))%24; System.out.println(\"当期时区的时间为:\"+currentHour+\"时\"+currentMinutes+\"分\"+currentSeconds+\"秒\");

System.out.print(\"请输入v0,v1,t:\"); double v0 =input.nextDouble(); double v1 =input.nextDouble(); double t =input.nextDouble(); float a = (float) ((v1-v0)/t);

System.out.println(\"平均加速度a=\"+a); System.out.println(\"输入水的重量、初始温度、最终温度:\"); double water =input.nextDouble(); double initialTemperature =input.nextDouble(); double finalTemperature = input.nextDouble(); double Q =water*(finalTemperature-initialTemperature)*4184; System.out.println(\"所需热量为:\"+Q); System.out.print(\"输入年数:\"); int numbers =input.nextInt(); long oneYearsSecond =365*24*60*60; Long population= (long) ((312032486+((oneYearsSecond/7.0)+(oneYearsSecond/45.0)-(oneYearsSecond/13.0))*numbers)); System.out.println(\"第\"+numbers+\"年后人口总数为:\"+population); System.out.print(\"输入速度单位m/s和加速度a单位m/s2 :\"); double v =input.nextDouble(); double a1 =input.nextDouble(); double lengthOfAirplane =(Math.pow(v, 2))/(2*a1); System.out.println(\"最短长度为:\"+lengthOfAirplane); System.out.print(\"输入存入的钱:\"); double money = input.nextInt(); double monthRate =5.0/1200; for(int i=1;i<7;i++){

double total =money*(Math.pow(1+monthRate,i));

System.out.println(\"第\"+i+\"个月的钱为:\"+total);//告诉我书上的银行在哪里,我要去存钱,半年本金直接翻6倍、、、 }

System.out.print(\"用户请输入身高(英寸)、体重(磅): \"); double height =input.nextDouble(); double weight =input.nextDouble();

double BMI =(weight*0.45359237)/(Math.pow((height*0.0254), 2)); System.out.println(\"BMI的值为\"+BMI); System.out.print(\"输入x1和y1:\"); System.out.print(\"输入x2和y2:\"); double x1 =input.nextDouble(); double y1 =input.nextDouble(); double x2 =input.nextDouble(); double y2 =input.nextDouble();

double point1 =Math.pow((x2-x1), 2);

double point2 =Math.pow((y2-y1), 2);

double distance =Math.pow((point1+point2), (1.0/2));//Math.pow((point1+point2),0.5) System.out.println(\"两点间的距离为:\"+distance); System.out.print(\"输入六边形的边长:\"); double side = input.nextDouble(); double area =(3*(Math.pow(3, 0.5))*(Math.pow(side, 2)))/2; System.out.println(\"六边形的面积为:\"+area); } }

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务