package dome;
public class MobilPhone {
public String brand;
public MobilPhone ( ) {
this . brand= "若基亚" ;
}
public MobilPhone ( String bra) {
this . brand= bra;
}
public String buy ( ) {
return "没发工资,买一个" + brand+ "牌子的手机吧!" ;
}
public String buy ( String reason) {
return reason+ ",快买一个" + brand+ "牌子的手机吧!" ;
}
}
package dome;
public class MobilPhoneText {
public static void main ( String[ ] args) {
MobilPhone mp= new MobilPhone ( ) ;
mp. brand= "苹果" ;
String detail= mp. buy ( "发工资啦" ) ;
System. out. println ( detail) ;
}
}
发工资啦, 快买一个苹果牌子的手机吧!
进程已结束,退出代码为 0
package unit;
public class One {
static int year;
static double a;
static double b;
static double c;
public double i ( double i, int yearchice) {
if ( yearchice== 1 ) {
a= 0.0603 ;
year= 36 ;
c= i* a;
} else if ( yearchice== 2 ) {
a= 0.0612 ;
year= 60 ;
c= i* a;
} else if ( yearchice== 3 ) {
a= 0.0639 ;
year= 240 ;
c= i* a;
}
b= ( i+ c) / year;
System. out. println ( "***月供为:" + b) ;
return b;
}
}
package unit;
import java. util. Scanner;
public class Two {
public static void main ( String[ ] args) {
One money= new One ( ) ;
Scanner input= new Scanner ( System. in) ;
System. out. println ( "请输入贷款金额:" ) ;
double i= input. nextDouble ( ) ;
System. out. println ( "\n请选择贷款年限:1.3年(36个月)2.5年(60个月)3.20年(240个月):" ) ;
int n= input. nextInt ( ) ;
money. i ( i, n) ;
}
}
请输入贷款金额:
10000
请选择贷款年限:1.3 年(36 个月)2.5 年( 60 个月)3.20 年( 240 个月):
2
* * * 月供为:176.86666666666667
进程已结束,退出代码为 0
package unit;
public class Triangle {
public boolean isTriangle ( int a, int b, int c) {
boolean flag = false ;
if ( a+ b> c&& a+ c> b&& b+ c> a) {
return true ;
} else {
System. out. println ( "边长为" + a+ " " + b+ " " + c+ "不能构成三角形" ) ;
}
return flag;
}
public String shape ( int a, int b, int c) {
String shape= "" ;
if ( a== b+ c && b== a+ c && c== a+ b) {
shape= "直角三角形" ;
System. out. println ( "这是一个" + shape) ;
} else if ( a< b+ c && b< a+ c && c< a+ b) {
shape= "锐角三角形" ;
System. out. println ( "这是一个" + shape) ;
}
else if ( a> b+ c && b> a+ c && c> a+ b) {
shape= "钝角山角形" ;
System. out. println ( "这是一个" + shape) ;
}
return shape;
}
}
package unit;
import java. util. Scanner;
public class Test {
public static void main ( String[ ] args) {
Scanner input= new Scanner ( System. in) ;
String hd= "" ;
do {
Triangle t = new Triangle ( ) ;
System. out. println ( "请输入第一个边长:" ) ;
int a = input. nextInt ( ) ;
System. out. println ( "请输入第二个边长:" ) ;
int b = input. nextInt ( ) ;
System. out. println ( "请输入第三个边上:" ) ;
int c = input. nextInt ( ) ;
t. isTriangle ( a, b, c) ;
t. shape ( a, b, c) ;
System. out. println ( "继续吗?(y/n)" ) ;
hd= input. next ( ) ;
if ( hd. equals ( "n" ) ) {
System. out. println ( "退出程序" ) ;
break ;
}
} while ( hd. equals ( "y" ) ) ;
}
}
请输入第一个边长:
2
请输入第二个边长:
1
请输入第三个边上:
1
边长为2 1 1 不能构成三角形
继续吗?(y/ n)
y
请输入第一个边长:
3
请输入第二个边长:
4
请输入第三个边上:
5
这是一个锐角三角形
继续吗?(y/ n)
y
请输入第一个边长:
6
请输入第二个边长:
6
请输入第三个边上:
6
这是一个锐角三角形
继续吗?(y/ n)
n
退出程序
进程已结束,退出代码为 0