In: Computer Science
Create a program that ask to input two users and the result will vary on their name with similar digits. In a game of F.L.A.M.E.S , it will count and repeat depends on their name that has a similar digit. For an Example (JOE RIZAL) and (JACKLYN BRACKEN) - JOE RIZAL has - 5 similar digits , while JACKLYN BRACKEN has 6 similar digits so a total of 11.
F - Friends - 1,7
L - Lover - 2,8
A - Anger - 3,9
M - Married - 4,10
E - ENEMY - 5,11 - therefore joe rizal and jacklyn are soulmate
S - SOULMATE - 6
use looping , switch statement , toupper , tolower , string , swap and much more...
// SAMPLE OUTPUT //
INPUT YOUR FULLNAME: JOE RIZAL
INPUT YOUR PARTNER FULL NAME: JACKLYN BRACKEN
RESULTS: JOE RIZAL AND JACKLYN BRACKEN ARE ENEMY.
#include<iostream>
#include<string.h>
#include<ctype.h>
using namespace std;
int main()
{
int count1=0,count2=0,count;
string s1,s2;
cout<<"Enter first name\t";
getline(cin,s1);
cout<<"enter second name\t";
getline(cin,s2);
int len1= s1.length();
int len2= s2.length();
for(int i=0;i<len1;i++)
{
if(islower(s1[i]))
s1[i]=toupper(s1[i]);
for(int j=0;j<len2;j++)
{
if(islower(s2[j]))
s2[j]=toupper(s2[j]);
if(s1[i]==s2[j])
{
++count1;
break;
}
}
}
for(int i=0;i<len2;i++)
{
if(islower(s2[i]))
s2[i]=toupper(s2[i]);
for(int j=0;j<len1;j++)
{
if(islower(s1[j]))
s1[j]=toupper(s1[j]);
if(s2[i]==s1[j])
{
++count2;
break;
}
}
}
count1--;//space is also counted, so decrease
one.
count2--;//space is also counted so decrease
one.
count=count1+count2;
if(count==0){
cout<<"NO MATCH FOUND";
}
else{
count=(count%6);
switch(count)
{
case 1:
cout<<"FRIENDS";
break;
case 2:
cout<<"LOVER";
break;
case 3:
cout<<"ANGER";
break;
case 4:
cout<<"MARRIED";
break;
case 5:
cout<<"ENEMY";
break;
case 0:
cout<<"SOULMATE";
break;
}
}
}
OUTPUT:
Enter first name JOE rizal
enter second name JACKlyn bracKEN
ENEMY
--------------------------------
Process exited after 29.72 seconds with return value 0
Press any key to continue . . .