HarrJ

Day 10 Math

Nov 19th, 2023
1,003
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. public class Day10B {
  2.     public static void main(String[] args) {
  3.         Day10B callMe = new Day10B();
  4.        
  5.         System.out.println(Math.E);
  6.        
  7.         System.out.println("square root of 25: " + Math.sqrt(25));
  8.        
  9.         System.out.println("cube root of 27: " + Math.cbrt(27));
  10.        
  11.         callMe.testRoundingNumber(0.25);
  12.         callMe.testRoundingNumber(0.5);
  13.         callMe.testRoundingNumber(0.75);
  14.         callMe.testRoundingNumber(10);
  15.         callMe.testRoundingNumber(10.20);
  16.         callMe.testRoundingNumber(10.57);
  17.     }
  18.    
  19.     void testRoundingNumber(double n1){
  20.         System.out.println("using rint: " + Math.rint(n1));
  21.         System.out.println("using round: " + Math.round(n1));
  22.         System.out.println("using floor: " + Math.floor(n1));
  23.         System.out.println("using ceil: " + Math.ceil(n1));
  24.         System.out.println("- - -\n");
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment