Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- public class untitled {
- public static void main (String[] args) {
- System.out.print("module: "+Mathematics.module(-14)+"\t "+"power: "+Mathematics.power(2,3)
- + "\t"+"area : "+Mathematics.area(2,5)+ "\t "+"length : "+ Mathematics.length(4) );
- }
- //
- public class Mathematics {
- public static int module(int num){
- String str = String.valueOf(num);
- String tmp = "";
- for(String n: str.split("")){
- if(!n.equals("-"))
- tmp = tmp + n;
- }
- int numm;
- numm = Integer.valueOf(tmp);
- return numm;
- }
- public static double power (double num, double pow){
- double n = 1;
- for(int i = 0; i < pow; i++){
- n = n*num;
- }
- return n;
- }
- public static double area (double width, double height){
- return (width*height);
- }
- public static double length (double radius){
- double pi = 3.14;
- return radius*2*pi;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment