-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_switchex.java
More file actions
47 lines (33 loc) · 1.36 KB
/
Copy pathMain_switchex.java
File metadata and controls
47 lines (33 loc) · 1.36 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
47
import java.util.Scanner;
public class Main_switchex {
public static void main(String[] args) {
String r;
Scanner sc = new Scanner(System.in);
do{
System.out.println("escolha entre 1- consultar saldo, 2-depositar, 3-sacar 0-encerrar: ");
int escolha= sc.nextInt();
double saldo= 500;
switch(escolha){
case 1:
System.out.println("Seu saldo é "+saldo);
break;
case 2:
System.out.print("Insira um valor válido: ");
saldo += sc.nextDouble();
System.out.printf("Seu saldo com o valor é:%2f" , saldo);
break;
case 3:
System.out.print("Insira um valor válido: ");
saldo -= sc.nextDouble();
if (saldo<0){
System.out.println("Saldo insuficiente");
break;
} break;
System.out.printf("Seu saldo com o valor é:%1f" , saldo);
case 0:
break;}
System.out.print("Digite r para retornar : ");
r= sc.next();}
while(r.equalsIgnoreCase("r"));
}
}