How to enter float values by user

1.How to enter float values by user

import java.util.*;

public class MEnterFloatValue
{
public static void main(String args[])
{
float f;
System.out.println("Enter the floating value: ");
Scanner sc=new Scanner(System.in);
f=sc.nextFloat();
System.out.println("You entered: "+f);


}
}


OUTPUT:
Enter the floating value:
12.121222
You entered: 12.121222

No comments:

Post a Comment