Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


boold
Question in Java ??
1 Answer(s)      2 years and 6 months ago
Posted in : Java Interview Questions


Welcome every One ,I have Q in Java :

Write aprogram that print the falewing table using SQRT method in the Math Class?

Number squrfoot ------- ------- 0 00000 2 1.4142 .
. . . 18 5.2426 20 5.4721

So thanks Every One .


Advertisement
View Answers

April 24, 2012 at 12:37 PM


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


Related Tutorials/Questions & Answers:
 

 

 

DMCA.com