Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int[] numArr = {24, 43, 56, 74, 49, 101, 213, 3, 89, 31, 72, 91, 99, 36, 72};
- System.out.println("Number of elements in the array: " + numArr.length);
- System.out.printf("Pick an element from %d to %d \n", 2, numArr.length - 2);
- int checkElement = Integer.parseInt(sc.nextLine());
- System.out.println(vrah(checkElement, numArr));
- System.out.println(dolina(checkElement, numArr));
- }
- public static boolean vrah(int element ,int...a){
- return (a[element] > a[element - 1] && a[element] > a[element + 1]);
- }
- public static boolean dolina(int element, int...a){
- return !(vrah(element, a));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement