0% found this document useful (0 votes)
40 views1 page

"Flames" "Enter The Name... " "Enter The 2name... ": in Out Out

This Java program takes in two names from the user, removes matching characters, determines the length of the remaining string, performs modulo operations on the length, and uses the resulting value to rotate the string "flames" and output a predicted relationship between the two people based on the first character of the rotated string.

Uploaded by

Praveen Kumar C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views1 page

"Flames" "Enter The Name... " "Enter The 2name... ": in Out Out

This Java program takes in two names from the user, removes matching characters, determines the length of the remaining string, performs modulo operations on the length, and uses the resulting value to rotate the string "flames" and output a predicted relationship between the two people based on the first character of the rotated string.

Uploaded by

Praveen Kumar C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package second;

import java.util.Scanner;
public class f {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String name,fname,flm="flames";
System.out.println("Enter the name...");
name=sc.next();
System.out.println("Enter the 2name...");
fname=sc.next();
int l=name.length();
int gl=fname.length();
int num=0,tl=0;
char n[]=name.toCharArray();
char gn[]=fname.toCharArray();
for(int i=0;i<l;i++)
{
for(int j=0;j<gl;j++)
{
if(n[i]==gn[j])
{
n[i]='*';
gn[j]='*';
break;
}
}
}
String tname=new String(n);
tname=tname+(new String(gn));
tname=tname.replace("*","");
tl=tname.length();
System.out.println(tl);
sc.close();
for(int s=6;s>=2;s--)
{
if(tl>s)
num=tl-s;
else
num=tl;
while(num>s)
{
num=num-s;
}
flm=flm.substring(num,flm.length())+(flm.substring(0,num-1));
}
switch(flm.charAt(0))
{
case 'f': System.out.println("Relationship = Friends"); break;
case 'l': System.out.println("Relationship = Lovers"); break;
case 'a': System.out.println("Relationship = Affections"); break;
case 'm': System.out.println("Relationship = Married"); break;
case 'e': System.out.println("Relationship = Enemy"); break;
case 's': System.out.println("Relationship = Brother & Sisters");
break;
}
}
}

You might also like