How to use else if with a function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to use else if with a function?

for example when you want a user to input his or her age and using the function to interact with the code.,,,like int x =10 if (x <=0) it should print error and so on....I want the int should be user input not fixed? help guys thanks in advance

1st May 2018, 11:52 AM
James John Chirwa
James John Chirwa - avatar
4 Answers
+ 8
You'll get help from this lesson on how to take user input in Java: https://www.sololearn.com/learn/Java/2220/ Also, here's a sample code for your convenience: https://code.sololearn.com/cMylYdRgkNft/?ref=app Hope it helps :)
1st May 2018, 4:21 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 4
The question is not clear enough. From the description I can assume that you're trying to take user input. Which programming language are you using?
1st May 2018, 12:04 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 3
java
1st May 2018, 3:52 PM
James John Chirwa
James John Chirwa - avatar
+ 2
You need to read input stream from keyboard and assign that value to x.
1st May 2018, 12:42 PM
D_Stark
D_Stark - avatar