Penpenqt69
Addict
- Joined
- Jul 31, 2018
- Posts
- 36
- Reaction
- 3
- Points
- 79
- Age
- 24
JavaScript:
import java.util.Scanner;
public class LoveCalcu {
public static void main(String[] args) {
String yourname="";
String crush="";
Scanner heya=new Scanner (System.in);
System.out.println("Enter Your Name:");
yourname=heya.next();
System.out.println("Enter Your Crush Name:");
crush=heya.next();
String yie=yourname+crush;
System.out.println(yie);
char[] characters = yie.toCharArray();
int length = characters.length;
for (int i = 0; i < length; i++) {
for (int j = i + 1; j < length; j++) {
if (characters[i] == characters[j]) {
int temp = j;//set duplicate element index
//delete the duplicate element by shifting the elements to left
for (int k = temp; k < length - 1; k++) {
characters[k] = characters[k + 1];
}
j--;
length--;//reduce char array length
}
}
}
String yiee = new String(characters);
yiee = yiee.substring(0, length);
int a=yie.length();
int b=yiee.length();
int c=a-b;
System.out.println(c+" letter r duplicated bish");
//eto na start ng condition paayos nalang concatination
if(c==2 || c==1){
System.out.println("Enemy");
} else if (c==3 ||c==4){
System.out.println("Friends");
} else if (c==5 ||c==6) {
System.out.println("Yie Lovers");
} else if (c==7 ||c==8) {
System.out.println("Affection");
} else if (c>=9){
System.out.println("Married");
} else {
System.out.println("Invalid");
}
System.out.println("String after duplicates r removed : " + yiee);
}
}
Enter Your Name:
1
Enter Your Crush Name:
2
12
0 letter r duplicated bish
Invalid
String after duplicates r removed : 12
ANG GUSTO KO PO SANANG GAWIN IS ONLY CHARACTERS LANG ANG MAKUKUHA PERO PAG NAG INPUT NUMBERS NAGBIBILANG PADIN SYA.
THANK YOU!!!