[SOLVED] Can I make a user input for a integer variable? Java
I'm trying to make a very simple calculator. I don't want to copy anyone's and it really will just be x + y =. I tried the scanner but it cant convert it to a int variable, does anyone know a way to do this?
When you code figure out what the result will be on the right hand side of the = and then make sure you assign this to the corrent type.
So you create a scanner object
Scanner sc = new Scanner(System.in);
This stores all the inputs so to find them you need to look inside the object and store it to the correct type.
(runs code and inputs 33);
int x = sc.nextInt();
First the right side of the code is computed which finds your integer input 33 and assigns this to x for you to use.
Blitzkriegster sorry for being harsh before, but there are way too many duplicates, and it's stressing. I hope you understand that I am just following the rules. But please take a look at the guidelines, to avoid this kind of answers next time. Thanks for understanding.
This question has already been asked, use the searchbar before posting next time please.