-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCasting.java
More file actions
46 lines (33 loc) · 1.09 KB
/
Casting.java
File metadata and controls
46 lines (33 loc) · 1.09 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
43
44
45
46
import javax.swing.plaf.synth.SynthOptionPaneUI;
public class Casting {
public static void main(String[] args) {
// en una año ubicar 30 perritos
// cuantos perritos ubique al mes
// manera 1
double monthlyDogs = 30.0/12.0;
System.out.println(monthlyDogs);
//manera 2
double mesesPerritos = 30.0;
System.out.println(mesesPerritos/12.0);
// manera 3
double mesesperritos = 30.0;
mesesperritos = mesesperritos / 12.0;
System.out.println(mesesperritos);
// Estimacion
int estimatedMonthlyDogs = (int) monthlyDogs;
System.out.println(estimatedMonthlyDogs);
// Exactitud
int a = 30;
int b = 12;
System.out.println((double)a/b);
// clase de casteo entre tipos de datos
double c1 = a/b;
double c = (double) a/b;
System.out.println(c);
char n = '1';
int nI = n;
System.out.println(nI);
short nS = (short) n;
System.out.println(nS);
}
}