-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmotion.java
More file actions
39 lines (39 loc) · 871 Bytes
/
Emotion.java
File metadata and controls
39 lines (39 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.*;
public class Emotion
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
System.out.println("Enter a string");
String s=in.nextLine();
int l=s.length();
if(l<1 || l>1000 || !(s.matches("^[a-z]+$"))){
System.out.println("Inavlid");
return;
}
int prev=0,not=0;
for(int i=0;i<l;i++)
{
if(s.charAt(0)==s.charAt(i))
prev++;
}
for(int i=1;i<l;i++)
{
int curr=0;
for(int j=0;j<l;j++)
{
if(s.charAt(i)==s.charAt(j))
curr++;
}
if(prev!=curr)
{
not++;
break;
}
}
if(not>=1)
System.out.println("Aashriya wonders: These thoughts were scattered");
else
System.out.println("Aashriya smiles: Emotional balance found");
}
}