JAVA整类实现调用互组整合.doc
文本预览下载声明
public class Chapter1 {
Fun fun= new Fun();
public void yl_Chapter1Question1() { // 一元二次方程
System.out.println(二元一次方程的a,b,c,d的取值分别为);
int a =fun.yl_Input();
int b = 0;
b = fun.yl_Input();
int c = 0;
c = fun.yl_Input();
int d = 0;
d =fun.yl_Input();
if (a == 0) {
if (b == 0 c == d) {
System.out.println(有无数解);
}
else if (b == 0 c != d) {
System.out.println(无解);
}
else {
System.out.println(x= + (d - c) / b);
}
}
else {
float e = b * b - 4 * a * (c - d);
if (e 0) {
System.out.println(无解);
}
else if (e == 0) {
System.out.println(x= + ( ( -b) / (2 * a)));
}
else {
System.out.println(x= + ( -b + Math.sqrt(e)) / (2 * a) + x= +
( -b - Math.sqrt(e)) / (2 * a));
}
}
}
public void yl_Chapter1Question2() { // 三天打渔两天晒网
System.out.println(从2000年1月1日起);
System.out.print(请输入year的值:);
int year = 0;
year = fun.yl_Input();
System.out.println(请输入month的值:);
int month = 0;
month = fun.yl_Input();
System.out.println(请输入day的值:);
int day = 0;
day =fun.yl_Input();
int i, sum = 0;
for (i = 2000; i year; i++) {
if ( (i % 4 == 0 i % 100 != 0) || i % 400 == 0) {
sum += 366;
}
else {
sum += 365;
}
} //年
for (i = 1; i month; i++) { //注意 imonth
switch (i) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: {
sum += 31;
break;
}
case 4:
case 6:
case 9:
case 11: {
sum += 30;
break;
}
case 2: {
if ( (year % 4 == 0 year % 100 != 0) || year % 400 == 0) {
sum += 29;
}
显示全部