Natalia__krkrkr

Математическая библиотека? :D

Aug 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. //
  2. public class untitled {
  3.     public static void main (String[] args) {
  4.         System.out.print("module: "+Mathematics.module(-14)+"\t "+"power: "+Mathematics.power(2,3)
  5.         + "\t"+"area : "+Mathematics.area(2,5)+ "\t "+"length : "+ Mathematics.length(4) );
  6.     }
  7. //
  8. public  class  Mathematics {
  9.  
  10.     public static int module(int num){
  11.         String  str = String.valueOf(num);
  12.         String tmp = "";
  13.         for(String n: str.split("")){
  14.             if(!n.equals("-"))
  15.                 tmp = tmp + n;
  16.         }
  17.         int numm;
  18.         numm = Integer.valueOf(tmp);
  19.         return numm;
  20.     }
  21.  
  22.     public static double power (double num, double pow){
  23.         double n = 1;
  24.         for(int i = 0; i < pow; i++){
  25.             n = n*num;
  26.         }
  27.         return n;
  28.     }
  29.  
  30.     public static double area (double width, double height){
  31.         return (width*height);
  32.     }
  33.  
  34.     public static double length (double radius){
  35.         double pi = 3.14;
  36.         return radius*2*pi;
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment