+ 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");

30th Nov 2017, 2:47 AM
Unidentified
Unidentified - avatar
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
30th Nov 2017, 2:55 AM
Unidentified
Unidentified - avatar
+ 1
Thank you!
30th Nov 2017, 3:03 AM
Unidentified
Unidentified - avatar
0
complete your else block
30th Nov 2017, 2:52 AM
Faisal Rahman
Faisal Rahman - avatar
- 1
Replace x with age bcoz you are not defining x in this program
30th Nov 2017, 5:00 AM
Kvr Sudhir
Kvr Sudhir - avatar
- 2
Change x in your if statements to age and you should be golden!
1st Dec 2017, 11:09 AM
Joey Sparidaans
Joey Sparidaans - avatar