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

Spell

This Java code defines a spell class with a findValue method that compares two strings and returns 1 if they are equal or 0 if they are not equal. It iterates through the characters in reverse order and counts matches. The main method gets two user input strings, creates an EvaluateCodes object, and calls findValue to check if the strings are equal by printing Yes or No.

Uploaded by

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

Spell

This Java code defines a spell class with a findValue method that compares two strings and returns 1 if they are equal or 0 if they are not equal. It iterates through the characters in reverse order and counts matches. The main method gets two user input strings, creates an EvaluateCodes object, and calls findValue to check if the strings are equal by printing Yes or No.

Uploaded by

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

import java.io.

*;
import java.util.*;
public class spell {
int findValue(String a,String b) {
char[] c=a.toCharArray();
char[] d=b.toCharArray();
int temp=c.length-1;
int count=0;
}
{
if(c.length>=d.length)
{
for(int i=d.length-1;i>=0;i--)
{
if(d[i]==c[temp])
{
count++;
temp--;

}
}
}

if(count==d.length)
{
return 1; {
else

return 0;

}
public class Main {

public static void main(String[] args) throws Exception,IOException {


Scanner s=new Scanner(System.in);
String a=s.nextLine();
String b=s.nextLine();
EvaluateCodes e=EvaluateCodes();
if(e.findValue(a,b)==1)
{
System.out.println("Yes");
}
if(e.findValue(a,b)==0)
System.out.println("No");
}
}
}

You might also like