-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhard_word_easy_word.java
More file actions
63 lines (51 loc) · 1.21 KB
/
hard_word_easy_word.java
File metadata and controls
63 lines (51 loc) · 1.21 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.util.*;
import java.lang.*;
import java.io.*;
public class hard_word_easy_word
{
static boolean isVowel(char ch)
{
return ( ch == 'a' || ch == 'e' ||
ch == 'i' || ch == 'o' ||
ch == 'u');
}
// Method to calculate difficulty
static int calcDiff(String str)
{
String words[]=str.split(" ");
int lws=words.length;
int res=0,hw=0,ew=0,count=0;
String wd="";
for(int i=0;i<lws;i++)
{
wd=wd+words[i];
//int count=0;
for(int j=0;j<wd.length();j++)
{
char ch=wd.charAt(j);
// ch=ch.toLowerCase();
if(!isVowel(ch))
{
count++;
}
if(count>=4||count>wd.length()/2)
{
hw++;
}
}
if(count<4||count<wd.length()/2)
{
ew++;
}
count=0;
wd="";
}
return 5*hw + 3*ew;
}
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
String data = sc.nextLine();
System.out.println(calcDiff(data));
}
}