Java语言程序设计与数据结构(基础篇)课后练习题 第二章

System.out.print(“Enter a value for feet:”);

double feet = input.nextDouble();

double meters = feet*0.305;

System.out.println(feet+" feet is “+meters+” meters.");

}

}

2.4

================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter a value in pounds:”);

double pounds = input.nextDouble();

double kilograms = pounds*0.454;

System.out.println(pounds+" pounds is “+kilograms+” kilograms.");

}

}

2.5

================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter the subtotal and a gratuity rate:”);

double t = input.nextDouble();

double g = input.nextDouble();

double extra = t*g/100.0;

double s = extra+t;

System.out.println(“The gratuity is $”+extra+" and total is $“+s+”.");

}

}

2.6

================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter a number between 0 and 1000:”);

int num = input.nextInt();

int d1 = num%10;

num/=10;

int d2 = num%10;

num/=10;

int s = num+d1+d2;

System.out.println(“The sum of the digits is “+s+”.”);

}

}

2.7

================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter the number of minutes:”);

int min = input.nextInt();

int days = min/60/24;

int years = days/365;

days %= 365;

System.out.println(min+" minutes is approximately “+years+” years and “+days+” days.");

}

}

2.8

================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter the time zone offset to GMT:”);

long offset = input.nextLong();

long totalMilliseconds = System.currentTimeMillis();

totalMilliseconds+=offset6060*1000;

long totalSeconds = totalMilliseconds/1000;

long currentSecond = totalSeconds%60;

long totalMinutes = totalSeconds/60;

long currentMinute = totalMinutes%60;

long totalHours = totalMinutes/60;

long currentHour = totalHours%24;

System.out.println(“Current time is “+currentHour+”:”+currentMinute+“:”+currentSecond+" GMT.");

}

}

2.9

================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter v0, v1, and t:”);

double v0 = input.nextDouble();

double v1 = input.nextDouble();

double t = input.nextDouble();

double a = (v1-v0)/t;

System.out.println(“The average acceleration is “+a+”.”);

}

}

2.10

=================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter the amount of water in kilograms:”);

double m = input.nextDouble();

System.out.print(“Enter the initial temperature:”);

double it = input.nextDouble();

System.out.print(“Enter the final temperature:”);

double ft = input.nextDouble();

double q = m*(ft-it)*4184;

System.out.println(“The energy needed is “+q+”.”);

}

}

2.11

=================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter the number of years:”);

int year = input.nextInt();

double base = 312032486;

int secnum = 365243600;

for(int i=1;i<=year;i++)

base=base+secnum/7.0-secnum/13.0+secnum/45.0;

System.out.println(“The population in “+year+” years is “+base+”.”);

}

}

2.12

=================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter speed and acceleration:”);

double v = input.nextDouble();

double a = input.nextDouble();

double l = vv/(2a);

System.out.println(“The minimum runway length for this airplane is “+l+”.”);

}

}

2.13

=================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter the monthly saving amount:”);

double m = input.nextDouble();

double sum = 0.0;

for(int i=0;i<6;i++)

sum = (m+sum)*(1+0.00417);

System.out.println(“After the sixth month, the account value is $”+sum+“.”);

}

}

2.14

=================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter weight in pounds:”);

double pounds = input.nextDouble();

System.out.print(“Enter height in inches:”);

double inches = input.nextDouble();

double bmi = pounds0.4535927/(inchesinches0.02540.0254);

System.out.println(“BMI is “+bmi+”.”);

}

}

2.15

=================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter x1 and y1:”);

double x1 = input.nextDouble();

double y1 = input.nextDouble();

System.out.print(“Enter x2 and y2:”);

double x2 = input.nextDouble();

double y2 = input.nextDouble();

double d = Math.pow((x2-x1)(x2-x1)+(y2-y1)(y2-y1),0.5);

System.out.println(“The distance between the two points is “+d+”.”);

}

}

2.16

=================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter the length of the side:”);

double s = input.nextDouble();

double a = 3Math.pow(3,0.5)/2s*s;

System.out.println(“The area of the hexagon is “+a+”.”);

}

}

2.17

=================================================================

import java.util.Scanner;

public class dierzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print(“Enter the temperature in Fahrenheit:”);

double ta = input.nextDouble();

System.out.print(“Enter the wind speed (>=2) in miles per hour:”);

double v = input.nextDouble();

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注前端)
img

最后

javascript是前端必要掌握的真正算得上是编程语言的语言,学会灵活运用javascript,将对以后学习工作有非常大的帮助。掌握它最重要的首先是学习好基础知识,而后通过不断的实战来提升我们的编程技巧和逻辑思维。这一块学习是持续的,直到我们真正掌握它并且能够灵活运用它。如果最开始学习一两遍之后,发现暂时没有提升的空间,我们可以暂时放一放。继续下面的学习,javascript贯穿我们前端工作中,在之后的学习实现里也会遇到和锻炼到。真正学习起来并不难理解,关键是灵活运用。

CodeChina开源项目:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

css源码pdf

JavaScript知识点
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注前端)
[外链图片转存中…(img-5p7pGS4C-1712091245402)]

最后

javascript是前端必要掌握的真正算得上是编程语言的语言,学会灵活运用javascript,将对以后学习工作有非常大的帮助。掌握它最重要的首先是学习好基础知识,而后通过不断的实战来提升我们的编程技巧和逻辑思维。这一块学习是持续的,直到我们真正掌握它并且能够灵活运用它。如果最开始学习一两遍之后,发现暂时没有提升的空间,我们可以暂时放一放。继续下面的学习,javascript贯穿我们前端工作中,在之后的学习实现里也会遇到和锻炼到。真正学习起来并不难理解,关键是灵活运用。

CodeChina开源项目:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

[外链图片转存中…(img-cOapOeaC-1712091245403)]

[外链图片转存中…(img-58crAIGH-1712091245403)]

  • 13
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值