Read floating point number user input in java

Complete source code below, will show you how to wait and read floating point number user input in command prompt.

********************************************************************
COMPLETE SOURCE CODE FOR : ReadFloatingPointNumberUserInput.java
********************************************************************


import java.util.Scanner;

public class ReadFloatingPointNumberUserInput
{
public static void main(String[]args)
{
try
{
//Create a scanner object
//Scanner is a predefined class in java that will be use to scan text
//System.in is mean, we will receive input from standard input stream
Scanner readUserInput=new Scanner(System.in);

//Print into command prompt(Put a floating point number : )
System.out.print("Put a floating point number : ");

//Wait and READ FLOATING POINT NUMBER from user input after user hit 'Enter'
float myPointNumber=readUserInput.nextFloat();

//Print what store in myPointNumber
System.out.println("My floating point number is : "+myPointNumber);
}
catch(Exception exception)
{
//Error that will be print if user put other than floating point number
System.out.println("Hey !!! Don't put other than floating point number");
}
}
}


********************************************************************
JUST COMPILE AND EXECUTE IT
********************************************************************

RELAXING NATURE VIDEO