1636050033胡子辰的作业

1.
import java.util.Scanner;

public class test
{
public static void main(String[] args)
{
Scanner ELF=new Scanner(System.in);
double x1,x2,y1,y2;
System.out.println("请输入X1的值:");
x1 = Double.valueOf(ELF.nextLine());
System.out.println("请输入X2的值:");
x2 = Double.valueOf(ELF.nextLine());
System.out.println("请输入Y1的值:");
y1 = Double.valueOf(ELF.nextLine());
System.out.println("请输入Y2的值:");
y2 = Double.valueOf(ELF.nextLine());
System.out.println("距离是:"+ Math.pow((Math.pow((x2 - x1),2)+Math.pow((y2 - y1),2)),0.5));

}
}


2.

import java.util.Scanner;

public class test
{
public static void main(String[] args)
{
Scanner ELF=new Scanner(System.in);
String CH;
System.out.println("请输入一个0-1000的整数来求整数各位数的和");
Hyper = ELF.nextLine();
int test = Integer.valueOf(CH);
if(test > 0 && test <= 1000)
{
int a = test % 2;
int b = test / 10;
int c = test / 100;
System.out.println("总和为:" + (a + b + c));
}
else
{
System.out.println("错误");
}
}
}

posted @ 2017-09-16 00:08  ELF_CH  阅读(291)  评论(0编辑  收藏  举报