Untitled

Vicente Yummy
mail@pastecode.io avatar
unknown
java
2 years ago
1.1 kB
2
Indexable
Never
// Completed


import java.util.Scanner;

public class January8{
    public static void main(String[] args) {
        
        Scanner cin = new Scanner(System.in);
        double num[]=new double[7];
        String ordinalNum[]={"1st", "2nd", "3rd", "4th", "5th","6th","7th"};

        for(int i =0; i<7; i++){
            System.out.print("Input the "+ordinalNum[i]+ " number: ");
            num[i] = cin.nextDouble();
        }

        findMinNum(num);
        findMaxNum(num);
    }

    private static void findMinNum(double[] num) {
        double minNum = num[0];
        for(int i=1;i < num.length;i++){
          if(num[i] < minNum){
            minNum = num[i];
          }
        }
        System.out.println("The smallest value is "+minNum);
    }

    private static void findMaxNum(double[] num) {
        double maxNum = num[0];
        for(int i=1;i < num.length;i++){
          if(num[i] > maxNum){
            maxNum = num[i];
          }
        }
        System.out.println("The largest value is "+maxNum);
    }
}