2024年Java最全Java语言程序设计与数据结构(基础篇)课后练习题 第二章(1),携程Java面试题

最后

腾讯T3大牛总结的500页MySQL实战笔记意外爆火,P8看了直呼内行

腾讯T3大牛总结的500页MySQL实战笔记意外爆火,P8看了直呼内行

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

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

double twc = 35.74+0.6215ta-35.75Math.pow(v,0.16)+0.4275taMath.pow(v,0.16);

System.out.println("The wind chill is "+twc);

}

}

2.18

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

public class dierzhang {

public static void main(String[] args){

最后

这份《“java高分面试指南”-25分类227页1000+题50w+字解析》同样可分享给有需要的朋友,感兴趣的伙伴们可挑战一下自我,在不看答案解析的情况,测试测试自己的解题水平,这样也能达到事半功倍的效果!(好东西要大家一起看才香)

image

image

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

out.println("The wind chill is "+twc);

}

}

2.18

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

public class dierzhang {

public static void main(String[] args){

最后

这份《“java高分面试指南”-25分类227页1000+题50w+字解析》同样可分享给有需要的朋友,感兴趣的伙伴们可挑战一下自我,在不看答案解析的情况,测试测试自己的解题水平,这样也能达到事半功倍的效果!(好东西要大家一起看才香)

[外链图片转存中…(img-aVMBhlQV-1714863020788)]

[外链图片转存中…(img-y2yKH2IF-1714863020789)]

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值