-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPractica02.java
More file actions
54 lines (40 loc) · 825 Bytes
/
Practica02.java
File metadata and controls
54 lines (40 loc) · 825 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package Practica;
class Matematica {
private int a, b;
Matematica(int nro1, int nro2) {
this.a = nro1;
this.b = nro2;
}
public int sumar() {
return a + b;
}
public int restar() {
return a - b;
}
public int multiplicar() {
return a * b;
}
public int dividir() {
int resultdo = 0;
if (b != 0) {
resultdo = a / b;
} else {
System.out.println("Error: Division por cero");
}
return resultdo;
}
public void setA(int nro1) {
this.a = nro1;
}
public int getA() {
return a;
}
}
class Practica02 {
public static void main(String[] args) { // acá inicia todo
int nro1 = 5;
int nro2 = 5;
Matematica mat = new Matematica(nro1, nro2);
System.out.println("El resultado es: " + mat.sumar());
}// acá termina todo
}