输入一组数排序,最大值,整数偶数判断

package zzy;
import java.util.*;
import static java.lang.System.*;
/**
 *
 * @author Zhu Zhengyan
 */
public class zzy2 {
    public static void main(String[] args){
        
        Scanner in = new Scanner(System.in);
        int a;
        int x_;
        int y;
        double[] x = new double[5];
        a = in.nextInt();
        shu n = new shu(a);
        out.println(n.oushu());
        out.println(n.zheng());
        x_ = in.nextInt();
        y = in.nextInt();
        shu o = new shu(x_,y);
        out.println("较大的是"+o.max());
        out.println("输入5个数");
        for(int i = 0;i<5;i++){
            x[i] = in.nextDouble();
        }
        shu m = new shu(x);
        out.println("排序");
        out.println(m.paixu());
    }
}
class shu{
            private int x;
            private int y;
            
            private double[] a;
            public shu(int x){
                this.x = x;
            }
            public shu(int x,int y){
                this.x = x;
                this.y = y;
            }
            public shu(double[] a){
                this.a = a;
            }
            public String oushu(){
            if(x%2==0)
                return("是偶数");
            else
                return("不是偶数");
            }
            public String zheng(){
                if(x>0)
                    return("是整数");
                else
                    return("不是整数");
            }
            public int max(){
                if(x>=y)
                    return x;
                else
                    return y;
            }
            public String paixu(){
                Arrays.sort(a);  
                for(double b:a)   //for each循环
                    out.println(b);
                return(" ");
            }
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值