I'm working on an assignment and I keep getting a cannot find symbol error for Part 1 and 2 -- I'm not sure how to fix this because I defined the variable. I also need help with Part 3; I'm not quite sure how to do the placement of a letter and I need direction on what goes in the parentheses. Thanks in advance for any help that anyone can offer.
For Part 3 these are the directions: Input two String type variables. If "c" appears at the same index in both variables, print "Same place". If it appears before in the first variable, print "First". If it appears before in the second variable, print "Second". Otherwise, print "Can't decide!".
class Main {
public static void main(String[] args) {
String str1 = blue;
String str2 = red;
int int1 = 8;
int int2 = 9;
String str3 = chair;
String str4 = focus;
/* Part 1 */
if(str1.equals(str2)){
System.out.println("Similar variables inputted!");
}
else {
System.out.println("Two different variables!");
}
/* Part 2 */
if(int1.equals(int2)){
System.out.println("Equal");
}
else if(int1 > int2) {
System.out.println("First inputted variable is greater");
}
else {
System.out.println("Second inputted variables is greater");
}
/* Part 3 */
if(str3) {
System.out.println("Same place");
}
else if(){
System.out.println("First");
}
else if(){
System.out.println("Second");
}
else(){
System.out.println("Can't decide");
}
}
}
Aucun commentaire:
Enregistrer un commentaire