0
点赞
收藏
分享

微信扫一扫

Java tutorial for beginners: Math class

你的益达233 2022-01-14 阅读 54

Java tutorial for beginners: Math class

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		double x;
		double y;
		double z;
		
		Scanner scanner = new Scanner(System.in);
		System.out.println("Enter side x: ");
		x = scanner.nextDouble();
		System.out.println("Enter side y: ");
		y = scanner.nextDouble();
		
		z = Math.sqrt((x*x)+(y*y));
		
		System.out.println("The hypotenuse is : "+z);
		
		scanner.close();
	}
}
Enter side x: 
3
Enter side y: 
4
The hypotenuse is : 5.0
举报

相关推荐

0 条评论