java中南大学livelab习题.docVIP

  • 301
  • 0
  • 约4.01万字
  • 约 30页
  • 2017-06-27 发布于浙江
  • 举报
java中南大学livelab习题

1.5 import java.util.*; public class Exercise01_01 { public static void main(String[] args) { System.out.println(9.5*4.5-2.5*3/(45.5-3.5)); } } 1.11(人口预测)基于以下假设美国人口普查局的项目群: 每7秒一诞生 一人死亡每13秒 一个新移民每45秒 编写一个程序,以显示人口为每个未来五年。假设目前的人口为312032486和一年有365天。 1.3 P2numberExchange 将两个变量(a=10,b=20)的值交换,但要求不能使用额外的变量,只能通过简单的运算实现!请在控制台上以‘a=? b=?’的格式输出经过交互后的变量值。 写程序读取0~1000范围之间的整数,并把读取的整数的各个位段上的数字相加 Enter a number between 0 and 1000: 999 The sum of the digits is 27 import java.util.*; public class Exercise02_06 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println(?????0-1000????); int n; n=sc.nextInt(); int a,b,c; int m; a=n%10; b=(n/10)%10; c=n/100; m=a+b+c; System.out.println(m); } } 根据用户输入的时区信息,输出给定时区的当前时间Enter the time zone offset to GMT: ?5 The current time is 4:50:34 import java.util.Date; import java.util.TimeZone; import java.text.SimpleDateFormat; public class Exercise02_08 { public static void main(String[] args) { SimpleDateFormat format=new SimpleDateFormat(yyyy-MM-dd hh:mm:ss); Date date=new Date(); TimeZone zone=TimeZone.getTimeZone(GMT-5); format.setTimeZone(zone); System.out.println(format.format(date)); } } 给定两点坐标,计算两点的欧式距离Enter x1 and y1: 1.5 -3.4 Enter x2 and y2: 4 5 The distance between the two points is 8.764131445842194 import java.util.Scanner; public class Exercise02_15 { public static void main(String[] args) { Scanner in=new Scanner(System.in); System.out.println(??x1,y1:); double x1=in.nextDouble(); double y1=in.nextDouble(); System.out.println(??x2,y2:); double x2=in.nextDouble(); double y2=in.nextDouble();

文档评论(0)

1亿VIP精品文档

相关文档