Java input problem | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 4

Java input problem

I will create a simple program that converts inch to cm. It gets user data in double and multiplied it by 2.54 and stores it to a variable. But the problem is when I use Scanner and multiple it by 2.54 it says that you can not store a scanner value into a double! My question is when should I must use .nextDouble or is there a short way to convert sccaner to double? Ps: I read this program in js with no problem.

15th Jul 2019, 7:33 AM
Saeed
Saeed - avatar
3 Antworten
+ 6
Scanner sc = new Scanner(System.in); double cm = sc.nextDouble(); This is how you get input, wonder how you got problems.
15th Jul 2019, 8:25 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 10
Hello, 😊 If you need help you can post the code you are struggling with!  • SEARCH for similar QUESTIONS or ANSWERS before posting  • Include relevant TAGS  • https://www.sololearn.com/post/75089/?ref=app  • https://code.sololearn.com/WvG0MJq2dQ6y/
15th Jul 2019, 9:40 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 3
Prometheus 🇸🇬 Thank you very much.
15th Jul 2019, 9:05 AM
Saeed
Saeed - avatar