I'm trying to get the user to input their age and use that number in the final statement being "Your age is "
Bear with me as i am a beginner level coder. Thank you
Java
import java.util.scanner;
public class Exercise2 {
public static void main(String[] args) {
// INSERT YOUR CODE HERE
System.out.print("How old are you?");
int age = scanner.nextInt();
scanner.nextLine();
return age;
System.out.print("Your age is ");
}
}
#What is wrong with this code?
1 messages · Page 1 of 1 (latest)
Pleas read the #📄・posting-guidelines and make sure to follow them.
It's important that you format your code properly and add more details.
Glory be to the beginning stages of your journey. May you revise this attached image and see if any benefit may beseech you.
You must instantiate the Scanner
Also be ascertain that the capitalization is congruent with expectations.
I'm not sure what that means sorry
No worries
Also you are returning age which exits your program prematurely, even causing an error. I would advise you to watch a video on system I/o in Java.
https://m.youtube.com/watch?v=huZ1neRqNho&pp=ygUVamF2YSBzY2FubmVyIHR1dG9yaWFs
Java Programming: The Scanner Class in Java Programming
Topics Discussed:
- The Scanner Class in Java.
- Instantiating a Scanner object in Java.
- Input methods of a Scanner object in Java.
- Examples of reading the input from the keyboard in Java.
Follow Neso Academy on Instagram: @nesoacademy (https://bit.ly/2XP63OE)
Contribute: http://w...
Ok thank you
Triumph ever awaits you
This is pretty hard and its not even the hard stuff 😦
If you're a beginner, it's totally normal.
Yes early on these small details are overwhelming. Soon it’ll be natural
Just keep practicing
Keep coding watch a bunch of tutorials or read book/website guide (whatever works for you)
Any popular tutorial will help early on