Page 73 - CTS - CSA TP - Volume 2
P. 73

COMPUTER SOFTWARE APPLICATION - CITS




           }


           Output:














           5  Float
              •  Represents a 32-bit IEEE 754 floating-point.

              •  Methods include: floatValue(), doubleValue().
              Task_Float:  Here’s an example program demonstrating the use of methods inherited from the Number
              class for the Float class:

               public class FloatMethodsExample {
               public static void main(String[] args) {
                   // Example using Float class
                   Float floatValue = 3.14f;



                   // floatValue()
                   float floatResult = floatValue.floatValue();
                   System.out.println(“floatValue(): “ + floatResult);


                   // doubleValue()

                   double doubleResult = floatValue.doubleValue();
                   System.out.println(“doubleValue(): “ + doubleResult);
               }
           }



           Output:























                                                           58

                               CITS : IT & ITES - Computer Software Application - Exercise 90
   68   69   70   71   72   73   74   75   76   77   78