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

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

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);

相关文档
最新文档