+ 1
What's wrong with my code?
import java.util.Scanner; public class BigPartyInvite { public static void main(String[] args) { int age; Scanner s = new Scanner(System.in); System.out.println("How old are you?"); age = s.nextInt(); if(x > 0) { if(x >= 4 && x <= 13) { System.out.println("Go back to your mom kid"); } else if(x > 13) { System.out.println("Welcome. Be Cool!"); } }else { System.out.print("No");
7 Respostas
+ 1
Unfortunately sololearn has a writing limit on how much I can write but I did complete the else block
import java.util.Scanner;
public class BigPartyInvite {
public static void main(String[] args) {
int age;
Scanner s = new Scanner(System.in);
System.out.println("How old are you?");
age = s.nextInt();
if(x > 0) {
if(x >= 4 && x <= 13) {
System.out.println("Go back to your mom kid");
} else if(x > 13) {
System.out.println("Welcome. Be Cool!");
}
}else {
System.out.println("This isn't a joke get out!");
}
}
}
I put in -5 as my input and expected "This isn't a joke get out!" but I got a error
+ 1
Thank you!
0
complete your else block
- 1
Replace x with age bcoz you are not defining x in this program
- 2
Change x in your if statements to age and you should be golden!