-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_switch.java
More file actions
43 lines (36 loc) · 1.49 KB
/
Copy pathMain_switch.java
File metadata and controls
43 lines (36 loc) · 1.49 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
import java.util.Scanner;
public class Main_switch {
public static void main(String[] args){
String r;
Scanner sc = new Scanner(System.in);
do {
System.out.print("Digite a escolha entre 1 ou 2 ( 1 pra soma 2 pra subtrair)");
int x = sc.nextInt();
switch (x) {
case 1:
System.out.println("Opção a escolhida");
System.out.println("digite o numero da soma");
int n1 = sc.nextInt();
System.out.println("digite o numero 2 da soma");
int n2 = sc.nextInt();
int total = n1 - n2;
System.out.println(total);
break;
case 2:
System.out.println("Opção b escolhida");
System.out.println("digite o numero da subtração");
int n1menos = sc.nextInt();
System.out.println("digite o numero 2 da subtração");
int n2menos = sc.nextInt();
int totalmenos = n1menos + n2menos;
System.out.print(totalmenos);
break;
default:
System.out.println("Opção invalida");
}
System.out.println("para ver novamente, digite S");
r = sc.next();
} while (r.equalsIgnoreCase("S"));
sc.close();
}
}