一、题目描述
创建一个类,为该类定义三个构造函数,从键盘输入两个int值,三个double值,两个字符串,分别执行下列操作:(1)传递两个整数值并找出其中较大的一个值(2)2、传递三个double值并求出其乘积(3)3、传递两个字符串值并检查其是否相同(4)4、在main方法中测试构造函数的调用。
二、代码实现
import java.util.Scanner;
class check{
check(int a,int b){
if(a>b)
System.out.println(a);
else
System.out.println(b);
}
check(double x,double y,double z){
System.out.println(x*y*z);
}
check(String s1,String s2){
if(s1.equals(s2))
System.out.println("Yes");
else
System.out.println("No");
}
}
public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int a=in.nextInt();
int b=in.nextInt();
check check1=new check(a,b);
double x=in.nextDouble();
double y=in.nextDouble();
double z=in.nextDouble();
check check2=new check(x,y,z);
String s1= in.next();
String s2= in.next();
check check3=new check(s1,s2);
in.close();
}
}
三、结果展示
四、推荐
给大家推荐三款蓝牙耳机,下面的链接可以直接购买:
1、https://item.taobao.com/item.htm?ft=t&id=643733003968
2、https://item.taobao.com/item.htm?ft=t&id=642849670304
3、https://item.taobao.com/item.htm?ft=t&id=639886208479
由于是新开的淘宝店铺,购买时联系客服,下单即可享受红包,红包 不大也是一片心意哟。虽然是新店,但是质量是有保证的哦!