- import java.util.Scanner;
- class Inputs
- {
- public static void main(String args[])
- {
- int num;
- float fnum;
- String str;
- Scanner in = new Scanner(System. in );
-
- System.out.println("Enter a string: ");
- str = in .nextLine();
- System.out.println("Input String is: " + str + "\n");
-
- System.out.println("Enter a character: ");
- char c = in .next().charAt(0);
- System.out.println("Input String is: " + c + "\n");
-
- System.out.println("Enter an integer: ");
- num = in .nextInt();
- System.out.println("Input Integer is: " + num + "\n");
-
- System.out.println("Enter a float number: ");
- fnum = in .nextFloat();
- System.out.println("Input Float number is: " + fnum + "\n");
- }
- }
Thank you, keep learning and sharing