What code can we use for the user to input any figure or anything for us to use? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What code can we use for the user to input any figure or anything for us to use?

Say, user's name or his age which he inputs and the program tells whether he is eligible or not... Advance thnx

19th Jan 2017, 2:28 PM
Yadumeet Singh
Yadumeet Singh - avatar
1 Answer
+ 2
Here's how you can do input/output in java:- import java.util.*; public class Program { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("enter a number"); int d=sc.nextInt(); } } Similarly for other datatypes you can input using:- float d=sc. nextFloat() ; Double d=sc.nextDouble(); String p=sc. nextLine() ; char r=sc. nextChar() ;
19th Jan 2017, 2:36 PM
Harsimran Kaur Bindra
Harsimran Kaur Bindra - avatar