1.How to enter float variable in java
public class FloatExample
{
public static void main(String args[])
{
float a;
a=20.3432f;
System.out.println("Value of a is: "+a);
System.out.printf("Value of a is:%.2f",a);
/* Use this:There are other conversion characters you can use besides f:
d: decimal integer
o: octal integer
e: floating-point in scientific notation
*/
}
}
OUTPUT:
Value of a is: 20.3432
Value of a is:20.34
public class FloatExample
{
public static void main(String args[])
{
float a;
a=20.3432f;
System.out.println("Value of a is: "+a);
System.out.printf("Value of a is:%.2f",a);
/* Use this:There are other conversion characters you can use besides f:
d: decimal integer
o: octal integer
e: floating-point in scientific notation
*/
}
}
OUTPUT:
Value of a is: 20.3432
Value of a is:20.34
No comments:
Post a Comment