-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathSquareFigures.java
More file actions
56 lines (42 loc) · 1.31 KB
/
Copy pathSquareFigures.java
File metadata and controls
56 lines (42 loc) · 1.31 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
import java.util.*;
import java.io.*;
class Main {
public static String StringChallenge(String[] strArr) {
// Abdullah Tas
int point = 0 , comma = 0;
for ( int i = 0; i < strArr[0].length(); i++){
char letter = strArr[0].charAt(i);
if(letter=='.') point++;
if (letter==',') comma++;
if(point>1) return "false";
if(Character.isAlphabetic(letter)) return "false";
}
if (comma!=0){
String [] number = strArr[0].split(",");
// 1,453,44,443.03
for ( int i = 1 ; i<number.length-1 ; i++){
if (number[i].length()!=3) return "false";
}
//443.03
if(point!=0){
String last = number[number.length-1].substring(0,number[number.length-1].indexOf(".")); //(0,3)
if(last.length() != 3 ) return "false";
}
if(number[0].length()>3) return "false";
}else{ // 10.00
if(point != 0){
String last = strArr[0].substring(0,strArr[0].indexOf('.'));
if ( last.length() > 3 ) return "false";
}else{
// 1243
if (strArr[0].length() > 3) return "false";
}
}
return "true";
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(StringChallenge(s.nextLine()));
}
}