Monday, April 20, 2020

Problem 2(Equality)

Equality (100 Marks)

The new world believes in equality for everyone and that they must have equal rights and individual identity, regardless of what they are and from where they belong. In this problem, everyone should be present equally. The string may contain lowercase alphabets, uppercase alphabets, numbers or other characters but everyone should exist equally. If the string is such then print "Equality For Everyone" otherwise print "No Equality".

Input Format
The first line of input consists of numbers of test cases, T.
Next T lines consist of strings to check.


Constraints
1<= T <=10
1<= |string| <=1000


Output Format
Print the required output.

Sample TestCase 1
Input
3
aaabbBBAAA12345)(*&^
aa11BB!!!!!!
aWsEdR1!2@3#
Output
Equality For Everyone
No Equality
Equality For Everyone
Solutions:



















import java.io.*;
import java.util.*;
public class CandidateCode {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner (System.in);
String t = sc.nextLine();
int test = Integer.parseInt(t);
for(int j=0; j<test;j++){
int low=0, upper=0, special=0,num=0;
String str = sc.nextLine();
for(int i =0; i<str.length(); i++){
if(str.charAt(i)>='a' && str.charAt(i)<='z')
low++;
else if(str.charAt(i)>='A' && str.charAt(i)<='Z')
upper++;
else if(str.charAt(i)>='0' && str.charAt(i)<='9')
num++;
else if(str.charAt(i)=='!'||str.charAt(i)<='@'||str.charAt(i)=='('||str.charAt(i)==')'||str.charAt(i)=='*'||str.charAt(i)=='&'||str.charAt(i)=='^'||str.charAt(i)=='#')
special++;
}
if((low==upper) && (num==special) && (low==num) && (special==upper) && (low==special))
System.out.println("Equality For Everyone");
else
System.out.println("No Equality");
}
}
}

No comments:

Post a Comment