Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E62 {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- System.out.println("enter your number of inputs");
- int numberOfInputs = s.nextInt();
- int largestValue = 0;
- int smallestValue = 0;
- System.out.println("enter input value");
- int inputValue = s.nextInt();
- largestValue = inputValue;
- smallestValue = inputValue;
- for(int i = 1; i < numberOfInputs; i++){
- System.out.println("enter input value");
- inputValue = s.nextInt();
- if(inputValue > largestValue){
- largestValue = inputValue;
- }
- else if(inputValue < smallestValue){
- smallestValue = inputValue;
- }
- }
- System.out.println(largestValue + " is the largest value");
- System.out.println(smallestValue + " is the smallest value");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement