Java program to find the largest & smallest number in n numbers without using arrays

前端 未结 8 1123
天命终不由人
天命终不由人 2020-12-22 14:22

I could get the largest without using arrays but, unable to get the smallest one.

    public static void main(String[] args)
    {
        int smallest=0;
           


        
8条回答
  •  悲哀的现实
    2020-12-22 14:44

    import java.util.Scanner;
    
    public class LargestSmallestNumbers {
    
        private static Scanner input;
    
        public static void main(String[] args) {
           int count,items;
           int newnum =0 ;
           int highest=0;
           int lowest =0;
    
           input = new Scanner(System.in);
           System.out.println("How many numbers you want to enter?");
           items = input.nextInt();
    
           System.out.println("Enter "+items+" numbers: ");
    
    
           for (count=0; count

提交回复
热议问题