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

文章展示了几个Java程序,涉及用户输入处理、温度/速度计算、日期验证、点在几何形状中的判断,以及卡片随机选择和线性方程求解,展示了基础的IT技术应用。
摘要由CSDN通过智能技术生成

import java.util.Scanner;

public class disanzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print("Enter the temperature: ");

double t = input.nextDouble();

System.out.print("Enter the velocity: ");

double v = input.nextDouble();

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

if(t>=-58&&t<=41&v>=2)

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

else

System.out.println(“Invalid input.”);

}

}

3.21

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

import java.util.Scanner;

public class disanzhang {

public static void main(String[] args){

int[] mdays = {31,28,31,30,31,30,31,31,30,31,30,31};

Scanner input = new Scanner(System.in);

System.out.print(“Enter year: (e,g.,2012):”);

int year = input.nextInt();

System.out.print("Enter month: 1-12: ");

int month = input.nextInt();

if((year%40&&year%100!=0)||(year%4000))

mdays[1]=29;

System.out.print(“Enter the day of the month: 1-”+mdays[month-1]+": ");

int q = input.nextInt();

if(month1||month2){

month+=12;

year–;

}

int h=(q+26*(month+1)/10+year%100+year%100/4+year/100/4+5*(year/100))%7;

String[] days = {“Sat”,“Sun”,“Mon”,“Tue”,“Wed”,“Thu”,“Fri”};

System.out.println("Day of the week is "+days[h]);

}

}

3.22

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

import java.util.Scanner;

public class disanzhang {

public static void main(String[] args){

System.out.print("Enter a point with two coordinates: ");

Scanner input = new Scanner(System.in);

double x = input.nextDouble();

double y = input.nextDouble();

if(xx+yy>100)

System.out.println(“Point (”+x+“, “+y+”) is not in the circle”);

else

System.out.println(“Point (”+x+“, “+y+”) is in the circle”);

}

}

3.23

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

import java.util.Scanner;

public class disanzhang {

public static void main(String[] args){

System.out.print("Enter a point with two coordinates: ");

Scanner input = new Scanner(System.in);

double x = input.nextDouble();

double y = input.nextDouble();

if(x<=10/2&&x>=-10/2&&y<=5.0/2&&y>=-5.0/2)

System.out.println(“Point (”+x+“, “+y+”) is in the rectangle”);

else

System.out.println(“Point (”+x+“, “+y+”) is not in the rectangle”);

}

}

3.24

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

public class disanzhang {

public static void main(String[] args){

int num = (int)(Math.random()*13);

int dick = (int)(Math.random()*4);

String[] nums = {“Ace”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“10”,“Jack”,“Queen”,“King”};

String[] dicks = {“Clubs”,“Diamonds”,“Hearts”,“Spades”};

System.out.println("The card you picked is “+nums[num]+” of "+dicks[dick]);

}

}

3.25

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

import java.util.Scanner;

public class disanzhang {

public static void main(String[] args){

System.out.print("Enter x1, y1, x2, y2, x3, y3, x4, y4: ");

Scanner input = new Scanner(System.in);

double x1 = input.nextDouble();

double y1 = input.nextDouble();

double x2 = input.nextDouble();

double y2 = input.nextDouble();

double x3 = input.nextDouble();

double y3 = input.nextDouble();

double x4 = input.nextDouble();

double y4 = input.nextDouble();

double a = y1-y2;

double b = x2-x1;

double c = y3-y4;

double d = x4-x3;

double e = (y1-y2)*x1-(x1-x2)*y1;

double f = (y3-y4)*x3-(x3-x4)*y3;

double jb = ad-bc;

if(jb==0)

System.out.println(“The two lines are parallel”);

else

System.out.println(“The intersecting point is at (”+(ed-bf)/jb+“, “+(af-ec)/jb+”)”);

}

}

3.26

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

import java.util.Scanner;

public class disanzhang {

public static void main(String[] args){

System.out.print("Enter an integer: ");

Scanner input = new Scanner(System.in);

int n = input.nextInt();

System.out.println("Is “+n+” divisible by 5 and 6? "+(n%50&&n%60));

System.out.println("Is “+n+” divisible by 5 or 6? "+(n%50||n%60));

System.out.println("Is “+n+” divisible by 5 or 6, but not both? "+(n%50^n%60));

}

}

3.37

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

import java.util.Scanner;

public class disanzhang {

public static void main(String[] args){

System.out.print("Enter a point’s x- and y- coordinates: ");

Scanner input = new Scanner(System.in);

double x = input.nextDouble();

double y = input.nextDouble();

if(x>=0&&x<=200&&y>=0&&y<=100-0.5*x)

System.out.println(“The point is in the triangle”);

else

System.out.println(“The point is not in the triangle”);

}

}

3.28

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

import java.util.Scanner;

public class disanzhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print("Enter r1’s center x-, y-coordinates, width, and height: ");

double x1 = input.nextDouble();

double y1 = input.nextDouble();

double w1 = input.nextDouble();

double h1 = input.nextDouble();

System.out.print("Enter r2’s center x-, y0coordinates, width, and height: ");

double x2 = input.nextDouble();

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

深知大多数初中级前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Web前端开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

img
img
img
img

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

如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注:前端)
img

最后

喜欢的话别忘了关注、点赞哦~

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

前端校招面试题精编解析大全

…(img-AZnT20Wi-1710604376428)]
[外链图片转存中…(img-Sgt8ht6P-1710604376429)]

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

如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注:前端)
[外链图片转存中…(img-LDPYHKhL-1710604376429)]

最后

喜欢的话别忘了关注、点赞哦~

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

前端校招面试题精编解析大全

  • 20
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值