intro/NumberExpressions

From ggc

Jump to: navigation, search

01 package intro;
02 
03 import wiki.Wiki;
04 
05 /**
06  * All about my application.
07  @author My Name Here
08  */
09 public class NumberExpressions
10 {
11   public static void main(String[] args)
12   {
13     double c=0.00034;
14     double result=-Math.log10(c);
15     int rounded=(int)Math.round(result);// dont do (int)result because it truncates, not rounds
16     double nearestTenth=Math.round(result*10)/10.0;
17     double a=3;
18     double b=4;
19     double hypotenuse=Math.sqrt(a*a+b*b);//Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2));
20     double discriminant=b*b-4*a*c;
21     double root1=(-b+Math.sqrt(discriminant))/(2*a);
22     double root2=(-b-Math.sqrt(discriminant))/(2*a);
23     Wiki.out.println("The result is "+result);
24     Wiki.out.println("The rounded result is "+rounded);
25     Wiki.out.println("The rounded to tenth result is "+nearestTenth);
26   }
27 }


Download/View intro/NumberExpressions.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter