-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflames.java
63 lines (58 loc) · 1.83 KB
/
flames.java
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.Scanner;
public class flames {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter G's Name: ");
String gname = sc.nextLine().toUpperCase();
System.out.println("Enter B's Name: ");
String bname = sc.nextLine().toUpperCase();
StringBuilder name1 = new StringBuilder(gname);
StringBuilder name2 = new StringBuilder(bname);
for(int i =0;i<gname.length();i++) {
for(int j=0;j<bname.length();j++) {
if(name1.charAt(i)==(name2.charAt(j))) {
name1.replace(i,i+1,"#");
name2.replace(j,j+1,"#");
}
}
}
String tempG = name1.toString();
String tempB = name2.toString();
String firstName = tempG.replace("#","");
String secondName = tempB.replace("#","");
String fname = firstName+secondName;
int fcount = fname.length();
StringBuilder flames = new StringBuilder("FLAMES");
String result = "";
while(flames.length()!=1) {
int index = fcount%flames.length();
if(index!=0) {
result = flames.substring(index)+flames.substring(0,index-1);
}
else
result = flames.substring(0,flames.length()-1);
flames = new StringBuilder(result);
}
switch(result.charAt(0))
{
case 'F':
System.out.println("Friends");
break;
case 'L':
System.out.println("Love");
break;
case 'A':
System.out.println("Affection");
break;
case 'M':
System.out.println("Marriage");
break;
case 'E':
System.out.println("Enemy");
break;
case 'S':
System.out.println("Sibling");
break;
}
}
}