-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunciones.java
More file actions
42 lines (40 loc) · 1.33 KB
/
Funciones.java
File metadata and controls
42 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
public class Funciones {
public static void main(String[] args) {
double y = 3;
// area de un circulo: pi * r2
circleArea(y);
// area de una esfera: 4 * pi * r2
sphereArea(y);
// volumen de una esfera: (4/3) * pi * r3
sphereVolumen(y);
System.out.println( " Pesos a dolares: " + converToDolar(1000, "COP"));
}
public static double circleArea(double r) {
return Math.PI * Math.pow(r,2);
}
public static double sphereArea (double r) {
return 4 * Math.PI * Math.pow(r, 2);
}
public static double sphereVolumen (double r) {
return (4/3) * Math.PI * Math.pow(r,3);
}
/**
* Descripcion: Funcion que especificando su moneda convierte una cantidad de dinero a dolares
*
* @param quantity Cantidad de dinero
* @param currency Tipo de Moneda: Solo acepta MXN o COP
* @return quantity Devuelve la cantidad actualizada en Dolares
*/
public static double converToDolar(double quantity, String currency) {
// mxm cop
switch (currency) {
case "MXN":
quantity = quantity * 0.052;
break;
case "COP":
quantity = quantity * 0.00031;
break;
}
return quantity;
}
}