0

What's wrong in the code?

import java.util.Scanner; class variable { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Enter your AGe"); int x = scanner.nextInt(); int y = 2 * x; System.out.printf("Yor lived %dyears old and next %d years old you will become %dyears old",x,x,y); } }

6th Jun 2020, 8:45 PM
Aditya Kumar Srivastav
Aditya Kumar Srivastav - avatar
5 Answers
+ 2
Why do you think something is wrong in it?it outputs correct answer tho
6th Jun 2020, 9:29 PM
Abhay
Abhay - avatar
+ 1
Nothing, it works alright. Why, do you get any error message?
6th Jun 2020, 9:31 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 1
Idk but it says there should be a public class.
6th Jun 2020, 9:33 PM
Aditya Kumar Srivastav
Aditya Kumar Srivastav - avatar
6th Jun 2020, 9:43 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 1
Thanks👏
6th Jun 2020, 9:53 PM
Aditya Kumar Srivastav
Aditya Kumar Srivastav - avatar