Statement
Check if two string are same are not if yes print True and if not Print False, dont use any inbuilt function.
Input 1 :
horse
house
Output 1 :
False
Input 2 :
house
house
Output 1 :
True
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
String str1 = sc.nextLine();
int count =0;
if(str1.length()!=str.length()){ /* if both string have different length return false*/
System.out.println("Fasle");
}else { /* else check each alphabet and compare each alphabet */
for(int i=0;i<str.length();i++){
if(str.charAt(i)==str1.charAt(i)){ /* checking if each alphabet i.e. str1 and str are same are not */
count++; /* if the alphabet are same increase the count by one */
}
}
if(count == str.length()){ /* so if count is same as the length of any one string */
System.out.println("True");
}else{
System.out.println("Fasle");
}
}
}
}
I will be updating this section in ide in couple of days ;)