0
Why does this code have an error called bad operand. Also, are we learning java 7 or 8?
import java.util.Scanner; public class Program { public static void main(String[] args) { System.out.println("Enter your age: "); Scanner age = new Scanner(System.in); int agevalue = age.nextInt(); if(age <= 0) { System.out.println("Error"); } else if(age <= 16) { System.out.println("Too Young"); } else if(age < 100) { System.out.println("Welcome!"); } else { System.out.println("Really?"); } } }
2 Antworten
+ 8
You are using `age` (object of Scanner class) instead of `agevalue` (integer storing the input value) in your `if` conditions.
+ 1
Oh bro thanks alot