How do I get the max and min values from a set of numbers entered?

后端 未结 8 1038
终归单人心
终归单人心 2020-11-28 15:52

Below is what I have so far:

I don\'t know how to exclude 0 as a min number though. The assignment asks for 0 to be the exit number so I need to have the lowest numb

8条回答
  •  孤独总比滥情好
    2020-11-28 16:46

    //for excluding zero
    public class SmallestInt {
    
        public static void main(String[] args) {
    
            Scanner input= new Scanner(System.in);
    
            System.out.println("enter number");
            int val=input.nextInt();
            int min=val;
    
            //String notNull;
    
            while(input.hasNextInt()==true)
            {
                val=input.nextInt();
                if(val

提交回复
热议问题