Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class SmallestLargest {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int n,i;
- System.out.print("Enter How Many Number You Want To Insert : ");
- n = input.nextInt();
- int arr[] = new int [n];
- System.out.println("Enter Your "+n+ " Numbers");
- for(i=0;i<n;i++)
- {
- arr[i]= input.nextInt();
- }
- int max = arr[0];
- for(i = 1; i < n; i++)
- {
- if(arr[i] > max)
- {
- max = arr[i];
- }
- }
- System.out.println("The Maximum value: "+max);
- int min = arr[0];
- for(i = 1;i < n;i++)
- {
- if(arr[i] < min)
- {
- min = arr[i];
- }
- }
- System.out.println("The Minimum value: "+min);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement