-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculadora.java
55 lines (45 loc) · 1.63 KB
/
calculadora.java
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
55
import java.util.Scanner;
////////////////////////////////////////////////
public class calculadora {
public static void main (String[] args){
////////////////////////////////////////////////
Scanner sc = new Scanner(System.in);
////////////////////////////////////////////////
System.out.print("ingrese el primer numero");
double numero1 = sc.nextDouble();
System.out.print("ingrese el segundo numero");
double numero2 = sc.nextDouble();
System.out.print("ingrese la operacion a realizar + - * /");
char operation = sc.next().charAt(0);
double result;
//////////////////////////////////////////////////
switch (operation){
case '+':
result = numero1 + numero2;
System.out.println("resultado"+resultado);
break;
case '-':
result - numero1 - numero2:
System.out.println("resultado"+resultado);
break;
case '*':
result = numero1 * numero2:
System.out.println("resultado"+resultado):
break;
case '/':
if (numero2 != 0){
result = numero1 / numero2:
System.out.println("resultado"+resultado);
else {
System.out.println("no se puede dividir por cero");
}
break;
///////////////////////////////////////////////////
default:
System.out.println("operacion no valida");
break;
}
//////////////////////////////////////////////////
sc.close();
}
}