- codewithshiva

Latest

Search Bar

Friday, July 2, 2021

 Sum and Conditions

Description

You are given an array of  N integers. Write a program that prints "Greater" (without quote) if the sum of all elements present in the array is greater than 100, else print "Lesser" (without quotes).

Input

Input format

First line contains N

Second line contains N space separated integers which are elements of the array.

Constraints

n<1000

Output

Output Format

Output Greater/Lesser depending upon the sum

Sample Input 1 

5
21 24 2 54 8

Sample Output 1

Greater

Hint

Sample 1 Explanation

Since, sum of all elements in array is 109, therefore Greater

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int iiyoo = sc.nextInt();
double[] stud1 = new double[iiyoo];
int add=0;

for (int i =0;i<iiyoo;i++){
stud1[i]= sc.nextInt();
add = (int) (stud1[i]+add);
}

if (add>100){
System.out.println("Greater");
}else {
System.out.println("Lesser");
}


}
}

No comments:

Post a Comment