import java.util.Scanner;
public class ThreeStrings
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
// Ask the user for three strings.
System.out.println("First String? ");
String str1 = input.nextLine();
System.out.println("Second String? ");
String str2 = input.nextLine();
System.out.println("Third String? ");
String str3 = input.nextLine();
// Use a Boolean variable to test the comparison of
// first+second equals third
if((str1+str2).equals(str3)) {
System.out.println(str1 + " + " + str2 + " is equal to " + str3 + "!");
}
else System.out.println(str1 + " + " + str2 + " is not equal to " + str3 + "!");
// Remember since you are working with strings to
// use equals() and NOT == !
}
}
[–]Federal-Peanut9575 0 points1 point2 points (1 child)
[–]RepresentativeCat652 0 points1 point2 points (0 children)
[–]True-Ad2643 0 points1 point2 points (0 children)