-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZodiacSignFinder.java
More file actions
102 lines (98 loc) · 2.99 KB
/
Copy pathZodiacSignFinder.java
File metadata and controls
102 lines (98 loc) · 2.99 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import java.util.Scanner;
import java.util.StringTokenizer;
public class ZodiacSignFinder {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i = 0;
System.out.println("Enter your Date of Birth in \"Date/Month\" format (eg: 08/May)");
String string = sc.nextLine();
String[] dateMonth = new String[2];
StringTokenizer separation = new StringTokenizer(string, "/");
while (separation.hasMoreTokens()) {
dateMonth[i] = separation.nextToken();
i++;
}
int date = Integer.parseInt(dateMonth[0]);
String month = dateMonth[1].toLowerCase();
String sign = zodiacFinder(date, month);
System.out.println("Your zodiac sign is: " + sign);
sc.close();
}
static String zodiacFinder(int date, String month) {
if (month.equals("january")) {
if (date <= 19) {
return "Capricorn";
} else {
return "Aquarius";
}
} else if (month.equals("february")) {
if (date <= 18) {
return "Aquarius";
} else {
return "Pisces";
}
} else if (month.equals("march")) {
if (date <= 20) {
return "Pisces";
} else {
return "Aries";
}
} else if (month.equals("april")) {
if (date <= 19) {
return "Aries";
} else {
return "Taurus";
}
} else if (month.equals("may")) {
if (date <= 20) {
return "Taurus";
} else {
return "Gemini";
}
} else if (month.equals("june")) {
if (date <= 20) {
return "Gemini";
} else {
return "Cancer";
}
} else if (month.equals("july")) {
if (date <= 22) {
return "Cancer";
} else {
return "Leo";
}
} else if (month.equals("august")) {
if (date <= 22) {
return "Leo";
} else {
return "Virgo";
}
} else if (month.equals("september")) {
if (date <= 22) {
return "Virgo";
} else {
return "Libra";
}
} else if (month.equals("october")) {
if (date <= 22) {
return "Libra";
} else {
return "Scorpio";
}
} else if (month.equals("november")) {
if (date <= 21) {
return "Scorpio";
} else {
return "Sagittarius";
}
} else if (month.equals("december")) {
if (date <= 21) {
return "Sagittarius";
} else {
return "Capricorn";
}
} else {
return "Invalid input";
}
}
}