//2.7import java.util.Scanner;publicclassDemo{publicstaticvoidmain(String[] args){
Scanner input =newScanner(System.in);
System.out.print("Enter the number of minutes: ");long minutes, years, days, allDays;
minutes = input.nextLong();
allDays = minutes /(60*24);
years = allDays /365;
days = allDays %365;
System.out.print(minutes +" minutes is approximately "+ years +" years and "+ days +" days ");}}
2.8
//2.8 (2-7改)import java.util.Scanner;publicclassDemo{publicstaticvoidmain(String[] args){
Scanner input =newScanner(System.in);
System.out.print("Enter the time zone offset to GMT: ");long zoneOffset = input.nextInt();long totalMilliSeconds = System.currentTimeMillis();long totalSeconds = totalMilliSeconds /1000;long currentSecond = totalSeconds %60;long totalMinutes = totalSeconds /60;long currentMinute = totalMinutes %60;long totalHours = totalMinutes /60;long currentHour = totalHours %24;
currentHour += zoneOffset;
System.out.print("The current time is "+ currentHour
+":"+ currentMinute +":"+ currentSecond);}}
2.17
//2.17import java.util.Scanner;publicclassDemo{publicstaticvoidmain(String[] args){
Scanner input =newScanner(System.in);double ta, v, twc, tmp;
System.out.println("Enter the temperature in Fahrenheit between -58°F and 41°F: ");
ta = input.nextDouble();
System.out.print("Enter the wind speed (>=2) in mils per hour: ");
v = input.nextDouble();
tmp = Math.pow(v,0.16);
twc =35.74+0.6215* ta -35.75* tmp +0.4275* ta * tmp;
System.out.println("The wind chill index is "+ twc);}}