第一章习题总结
public class Domo01 {
public static void main(String[] args){
double calculate = 0.0;
calculate = (9.5 * 4.5 - 2.5 * 3)/(45.5 - 3.5);
System.out.println(calculate);
}
}
这是相当简单的,直接将题中的算式写入到程序中即可 运算出结果
public class Domo02 {
public static void main (String [] args){
double runningsecond = 45 * 60 + 30;
double runninghour = runningsecond / (60 * 60);
System.out.println(14 / runninghour /1.6);
}
}
先把分钟转化成秒再转化为小时
注意整数型和浮点型区别
public class Demo03 {
public static void main(String[] args){
double V;
V =(1.6 * 24)/(1 + 40/60 +35/3600);
System.out.println(“The runner speed is” + V + “km/h”);
}
}
这道题是上一道题的逆运算
public class Demo04 {
public static void main(String[] args){
int second = 0;
int nowpeople = 312032486;
second = 365 * 24 *60 *60;
double birth = second / 7;
double death = second / 13;
double immigrant = second /45;
int oneyear = (int)(birth - death + immigrant);
int Firstyear = nowpeople + 1 * oneyear;
int Secondyear = nowpeople + 2 * oneyear;
int Thirdyear = nowpeople + 3 * oneyear;
int Fourthyear = nowpeople + 4 * oneyear;
int Fifthyears = nowpeople + 5 * oneyear;
System.out.println(Firstyear);
System.out.println(Secondyear);
System.out.println(Thirdyear);
System.out.println(Fourthyear);
System.out.println(Fifthyears);
}
}
注意逻辑 逻辑清晰即可
public class Demo05 {
public static void main(String[] args) {
double x = (44.5 * 0.55 - 50.2 * 5.9) / (3.4 * 0.55 - 50.2 * 2.1);
System.out.println(x);
double y = (3.4 * 5.9 - 44.5 * 2.1) / (3.4 * 0.55 - 50.2 * 2.1);
System.out.println(y);
}
}