Untitled
unknown
java
3 years ago
603 B
4
Indexable
class SetTesting
{
static int digSum(int n)
{
if (n == 0)
return 0;
return (n % 9 == 0) ? 9 : (n % 9);
}
public int getCodeThroughStrings(String str){
int cnt = 0;
for(int i=0;i<str.length();i++){
if(str.charAt(i) != ' '){
cnt++;
}
}
return digSum(cnt);
}
public static void main(String[] args){
String str = "Micro Technologies";
SetTesting test = new SetTesting();
int ans = test.getCodeThroughStrings(str);
System.out.println(ans);
}
}Editor is loading...