-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalc.java
More file actions
56 lines (53 loc) · 2.54 KB
/
Copy pathCalc.java
File metadata and controls
56 lines (53 loc) · 2.54 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
48
49
50
51
52
53
54
55
56
package br.com.bb.Calc;
import java.util.Arrays;
import java.util.Scanner;
public class Calc {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Operacoes ope = new Operacoes();
Boolean continuar = true;
while (continuar) {
SolveCient sol = new SolveCient(ope);
System.out.println("\033c");
System.out.println("=============================================");
System.out.println("| Quadro de operações possíveis |");
System.out.println("|-------------------------------------------|");
System.out.println("| multiplicação | * || mostrar memória | h |");
System.out.println("| divisão | / || sair | e |");
System.out.println("| adição | + || fatorial | f |");
System.out.println("| subtração | - || potencia | p |");
System.out.println("=============================================");
String entrada = sc.nextLine();
//String[] caracteres = entrada.trim().split(" ");
if (entrada.length() == 1)
{
switch (entrada.substring(0, 1)){
case "h":
System.out.println("Histórico");
System.out.println(Arrays.toString(ope.getMemory()));
break;
case "e":
continuar = false;
sol.demorou();
break;
case "f":
System.out.println("coloque numero para fatorial sem !");
sol.fatorial(Integer.parseInt(sc.nextLine()));
break;
case "p":
System.out.println("coloque o primeiro numero para para potencia");
Double a = Double.parseDouble(sc.nextLine());
System.out.println("coloque o Segundo numero para para potencia");
int b = Integer.parseInt(sc.nextLine());
System.out.println("Solução: " + sol.pow(a,b));
}
}
else if (entrada.length() >= 2 ) //entradas com quantidade par de caracteres não sâo válidas (( " 1 + 1 + ", ... ))
{
System.out.println(sol.solve(entrada));
}
System.out.println("Pressione ENTER para continuar");
sc.nextLine();
}
}
}