Question in Java ??

Question in Java ??

Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number
0 ,2, . . .

,18,20

squrfoot
00000 1.4142 5.2426 5.4721

View Answers

April 24, 2012 at 1:21 PM

The method Math.sqrt() gives the square root of 18 and 20- 4.2426 and 4.4721 respectively.

  import java.text.*;
 class SquareRoot 
    {
        public static void main(String[] args) 
        {
            DecimalFormat df=new DecimalFormat("##.####");
            System.out.println("Number  SquareRoot");
            for(int i=0;i<=20;i++){
                if(i%2==0){
                double sroot=Math.sqrt(i);
                System.out.println(i+" \t "+df.format(sroot));
                }
            }
        }
    }

April 24, 2012 at 2:09 PM

THANLS ALOOT MY FRIND ; have nice day









Related Tutorials/Questions & Answers:

Ads