-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethods.java
More file actions
24 lines (19 loc) · 819 Bytes
/
Methods.java
File metadata and controls
24 lines (19 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class Methods {
public static int addNumbers(int numberA, int numberB) { // definimos el método
// int numberA e int numberB son parámetros. Cualquier int que nos llegue cuando llamamos al método
return numberA + numberB;
}
public static int subNumbers(int numberA, int numberB) { // definimos el método
return numberA - numberB;
}
public static double calculateArea(double radius) {
double pi = Math.PI;
// to calculate a radius we need to multiply pi by the radius squared
return pi * Math.pow(radius, 2);
}
public static void main(String[] args) {
System.out.println(addNumbers(10, 10)); // ejecutamos el método
System.out.println(addNumbers(30, 12));
System.out.println(subNumbers(20,10));
}
}