NEED HELP String to int | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

NEED HELP String to int

I need to transfer the user input (String) into integers. The input is a date (mmdd). I want two numbers so I can calculate something with them. But I don't know how I get these in 2 ints.

29th Sep 2017, 1:01 PM
Selty
Selty - avatar
4 Answers
+ 6
public class Program { public static void main(String[] args) { int x = Integer.parseInt("9988")/100; int y = Integer.parseInt("9988")%100; System.out.println(x); System.out.println(y); } }
29th Sep 2017, 1:14 PM
Kartikey Sahu
Kartikey Sahu - avatar
+ 4
@Selty Glad to hear that
29th Sep 2017, 2:03 PM
Kartikey Sahu
Kartikey Sahu - avatar
+ 2
Thank you this helps me a lot :)
29th Sep 2017, 2:02 PM
Selty
Selty - avatar
+ 1
The code I used this for is now public! pls take a look :) https://code.sololearn.com/c4J2WMdT3Mv6/?ref=app
29th Sep 2017, 3:50 PM
Selty
Selty - avatar