fazendo os sistemas de clientes e do admin
This commit is contained in:
@@ -10,6 +10,7 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -30,21 +31,18 @@ public class Mavenproject25 {
|
|||||||
" Seleciona uma das opções\n" +
|
" Seleciona uma das opções\n" +
|
||||||
"══════════════════════════════════════\n" +
|
"══════════════════════════════════════\n" +
|
||||||
" [1] Contas clientes\n" +
|
" [1] Contas clientes\n" +
|
||||||
" [2] Emissão de cheques/letras\n" +
|
" [2] Login\n" +
|
||||||
" [3] Moeda\n" +
|
" [3] Sair\n" +
|
||||||
" [4] Sair\n" +
|
|
||||||
"══════════════════════════════════════"
|
"══════════════════════════════════════"
|
||||||
|
|
||||||
+ "\n");
|
+ "\n");
|
||||||
int opcao = scanner.nextInt();
|
int opcao = scanner.nextInt();
|
||||||
switch (opcao) {
|
switch (opcao) {
|
||||||
case 1 ->
|
case 1 -> acessoContaCliente();
|
||||||
contasClientes();
|
|
||||||
// case 2 ->
|
// case 2 ->
|
||||||
|
|
||||||
// case 3 ->
|
case 3 -> desligar = true;
|
||||||
|
|
||||||
case 4 -> desligar = true;
|
|
||||||
default ->
|
default ->
|
||||||
System.out.println("Opção inválida");
|
System.out.println("Opção inválida");
|
||||||
}
|
}
|
||||||
@@ -208,44 +206,527 @@ public class Mavenproject25 {
|
|||||||
* *****************************************opções da conta dos clientes****************************************************
|
* *****************************************opções da conta dos clientes****************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
private static String[] procurarClientePorId(String id) {
|
||||||
|
String nomeFicheiro = "clientes.txt";
|
||||||
|
|
||||||
|
if (getNumeroLinhasFicheiro(nomeFicheiro) == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] nome = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] idTitular = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] numeroTel = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] email = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] nif = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] saldoTxt = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
|
||||||
|
leExtraiCsvFicheiro(nomeFicheiro, nome, idTitular, numeroTel, email, nif, saldoTxt);
|
||||||
|
|
||||||
|
for (int i = 0; i < idTitular.length; i++) {
|
||||||
|
if (idTitular[i].equals(id)) {
|
||||||
|
return new String[]{nome[i], idTitular[i], numeroTel[i], email[i], nif[i], saldoTxt[i]};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void contasClientes() {
|
private static void acessoContaCliente() {
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
boolean sair = false;
|
|
||||||
while (true) {
|
|
||||||
|
|
||||||
|
System.out.print("Digite o seu ID de cliente: ");
|
||||||
|
String id = scanner.nextLine();
|
||||||
|
|
||||||
System.out.println("\n"
|
String[] dadosCliente = procurarClientePorId(id);
|
||||||
|
|
||||||
+ "╔════════════════════════════════════╗\n" +
|
if (dadosCliente != null) {
|
||||||
"║ Introduza opção: ║\n" +
|
System.out.println("\n Login realizado com sucesso!");
|
||||||
"╠════════════════════════════════════╣\n" +
|
menuClienteLogado(dadosCliente);
|
||||||
"║ ▸ 1 Adicionar cliente ║\n" +
|
} else {
|
||||||
"║ ▸ 2 Mostrar todos os clientes ║\n" +
|
System.out.println(" Cliente não encontrado! Verifique o ID.");
|
||||||
"║ ▸ 3 Procurar cliente ║\n" +
|
}
|
||||||
"║ ▸ 4 Sair ║\n" +
|
}
|
||||||
"╚════════════════════════════════════╝"
|
|
||||||
+ "\n");
|
|
||||||
|
|
||||||
int opcaoCliente = scanner.nextInt();
|
private static void menuClienteLogado(String[] dadosCliente) {
|
||||||
switch (opcaoCliente) {
|
Scanner scanner = new Scanner(System.in);
|
||||||
case 1 ->
|
boolean sair = false;
|
||||||
adicionarNovoCliente();
|
|
||||||
case 2 ->
|
|
||||||
mostrarTodosClientes();
|
|
||||||
case 3 -> procurarCliente();
|
|
||||||
case 4 -> sair = true;
|
|
||||||
|
|
||||||
default ->
|
double saldo = Double.parseDouble(dadosCliente[5]);
|
||||||
System.out.println("Opção invalida");
|
|
||||||
}
|
while (!sair) {
|
||||||
if (sair) {
|
System.out.printf("\n"
|
||||||
|
+ "╔════════════════════════════════════════╗\n"
|
||||||
|
+ "║ BEM-VINDO, %-15s ║\n"
|
||||||
|
+ "╠════════════════════════════════════════╣\n"
|
||||||
|
+ "║ SEU SALDO: €%.2f ║\n"
|
||||||
|
+ "╠════════════════════════════════════════╣\n"
|
||||||
|
+ "║ ▸ 1 Consultar meus dados ║\n"
|
||||||
|
+ "║ ▸ 2 Transferir dinheiro ║\n"
|
||||||
|
+ "║ ▸ 3 Depositar dinheiro ║\n"
|
||||||
|
+ "║ ▸ 4 Levantar dinheiro ║\n"
|
||||||
|
+ "║ ▸ 5 Sair ║\n"
|
||||||
|
+ "╚════════════════════════════════════════╝\n",
|
||||||
|
dadosCliente[0], saldo);
|
||||||
|
|
||||||
|
int opcao = scanner.nextInt();
|
||||||
|
|
||||||
|
switch (opcao) {
|
||||||
|
case 1:
|
||||||
|
mostrarDadosCliente(dadosCliente);
|
||||||
break;
|
break;
|
||||||
}
|
case 2:
|
||||||
|
saldo = transferirDinheiro(dadosCliente[1], saldo);
|
||||||
|
atualizarSaldoCliente(dadosCliente[1], saldo);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
saldo = depositarDinheiro(saldo);
|
||||||
|
atualizarSaldoCliente(dadosCliente[1], saldo);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
saldo = levantarDinheiro(saldo);
|
||||||
|
atualizarSaldoCliente(dadosCliente[1], saldo);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
sair = true;
|
||||||
|
System.out.println("A sair da conta...");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("Opção inválida!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void mostrarDadosCliente(String[] dados) {
|
||||||
|
System.out.println("\n╔════════════════════════════════════════╗");
|
||||||
|
System.out.println("║ SEUS DADOS PESSOAIS ║");
|
||||||
|
System.out.println("╠════════════════════════════════════════╣");
|
||||||
|
System.out.printf("║ Nome: %-25s ║\n", dados[0]);
|
||||||
|
System.out.printf("║ ID: %-25s ║\n", dados[1]);
|
||||||
|
System.out.printf("║ Telefone: %-25s ║\n", dados[2]);
|
||||||
|
System.out.printf("║ Email: %-25s ║\n", dados[3]);
|
||||||
|
System.out.printf("║ NIF: %-25s ║\n", dados[4]);
|
||||||
|
System.out.printf("║ Saldo: €%-24s ║\n", dados[5]);
|
||||||
|
System.out.println("╚════════════════════════════════════════╝\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double transferirDinheiro(String idOrigem, double saldoOrigem) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.print("Digite o ID do cliente destinatário: ");
|
||||||
|
String idDestino = scanner.nextLine();
|
||||||
|
|
||||||
|
if (idDestino.equals(idOrigem)) {
|
||||||
|
System.out.println("Não pode transferir para si mesmo!");
|
||||||
|
return saldoOrigem;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.print("Digite o valor a transferir: €");
|
||||||
|
double valor = scanner.nextDouble();
|
||||||
|
|
||||||
|
if (valor <= 0) {
|
||||||
|
System.out.println("Valor inválido!");
|
||||||
|
return saldoOrigem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valor > saldoOrigem) {
|
||||||
|
System.out.println("Saldo insuficiente!");
|
||||||
|
return saldoOrigem;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] dadosDestino = procurarClientePorId(idDestino);
|
||||||
|
|
||||||
|
if (dadosDestino == null) {
|
||||||
|
System.out.println("Cliente destinatário não encontrado!");
|
||||||
|
return saldoOrigem;
|
||||||
|
}
|
||||||
|
|
||||||
|
double saldoDestino = Double.parseDouble(dadosDestino[5]) + valor;
|
||||||
|
saldoOrigem -= valor;
|
||||||
|
|
||||||
|
atualizarSaldoCliente(idDestino, saldoDestino);
|
||||||
|
atualizarSaldoCliente(idOrigem, saldoOrigem);
|
||||||
|
|
||||||
|
System.out.printf("Transferência de €%.2f realizada com sucesso!\n", valor);
|
||||||
|
System.out.printf("Novo saldo: €%.2f\n", saldoOrigem);
|
||||||
|
|
||||||
|
return saldoOrigem;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double depositarDinheiro(double saldo) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.print("Digite o valor a depositar: €");
|
||||||
|
double valor = scanner.nextDouble();
|
||||||
|
|
||||||
|
if (valor <= 0) {
|
||||||
|
System.out.println("Valor inválido!");
|
||||||
|
return saldo;
|
||||||
|
}
|
||||||
|
|
||||||
|
saldo += valor;
|
||||||
|
System.out.printf("Depósito de €%.2f realizado com sucesso!\n", valor);
|
||||||
|
System.out.printf("Novo saldo: €%.2f\n", saldo);
|
||||||
|
|
||||||
|
return saldo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double levantarDinheiro(double saldo) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.print("Digite o valor a levantar: €");
|
||||||
|
double valor = scanner.nextDouble();
|
||||||
|
|
||||||
|
if (valor <= 0) {
|
||||||
|
System.out.println("Valor inválido!");
|
||||||
|
return saldo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valor > saldo) {
|
||||||
|
System.out.println("Saldo insuficiente!");
|
||||||
|
return saldo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saldo - valor < 60) {
|
||||||
|
System.out.println("Operação não permitida! Saldo mínimo de 60€ deve ser mantido.");
|
||||||
|
return saldo;
|
||||||
|
}
|
||||||
|
|
||||||
|
saldo -= valor;
|
||||||
|
System.out.printf("Levantamento de €%.2f realizado com sucesso!\n", valor);
|
||||||
|
System.out.printf("Novo saldo: €%.2f\n", saldo);
|
||||||
|
|
||||||
|
return saldo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void atualizarSaldoCliente(String id, double novoSaldo) {
|
||||||
|
String nomeFicheiro = "clientes.txt";
|
||||||
|
|
||||||
|
String[] nome = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] idTitular = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] numeroTel = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] email = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] nif = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] saldoTxt = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
|
||||||
|
leExtraiCsvFicheiro(nomeFicheiro, nome, idTitular, numeroTel, email, nif, saldoTxt);
|
||||||
|
|
||||||
|
StringBuilder novoConteudo = new StringBuilder();
|
||||||
|
for (int i = 0; i < idTitular.length; i++) {
|
||||||
|
if (idTitular[i].equals(id)) {
|
||||||
|
saldoTxt[i] = Double.toString(novoSaldo);
|
||||||
|
}
|
||||||
|
novoConteudo.append(nome[i]).append(",")
|
||||||
|
.append(idTitular[i]).append(",")
|
||||||
|
.append(numeroTel[i]).append(",")
|
||||||
|
.append(email[i]).append(",")
|
||||||
|
.append(nif[i]).append(",")
|
||||||
|
.append(saldoTxt[i]).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
escreveNoFicheiro(novoConteudo.toString(), nomeFicheiro);
|
||||||
|
}
|
||||||
|
// ==================== ÁREA DO ADMIN ====================
|
||||||
|
|
||||||
|
private static final String ADMIN_USERNAME = "admin123";
|
||||||
|
private static final String ADMIN_PASSWORD = "admin123";
|
||||||
|
|
||||||
|
private static void areaAdmin() {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.println("\n╔════════════════════════════════════════╗");
|
||||||
|
System.out.println("║ LOGIN DE ADMIN ║");
|
||||||
|
System.out.println("╚════════════════════════════════════════╝");
|
||||||
|
|
||||||
|
System.out.print("Usuário: ");
|
||||||
|
String username = scanner.next();
|
||||||
|
|
||||||
|
System.out.print("Senha: ");
|
||||||
|
String password = scanner.next();
|
||||||
|
|
||||||
|
if (username.equals(ADMIN_USERNAME) && password.equals(ADMIN_PASSWORD)) {
|
||||||
|
System.out.println("Login de admin realizado com sucesso!\n");
|
||||||
|
menuAdmin();
|
||||||
|
} else {
|
||||||
|
System.out.println("Credenciais inválidas! Acesso negado.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void menuAdmin() {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
boolean sair = false;
|
||||||
|
|
||||||
|
while (!sair) {
|
||||||
|
System.out.println("\n"
|
||||||
|
+ "╔════════════════════════════════════════╗\n"
|
||||||
|
+ "║ PAINEL DE ADMIN ║\n"
|
||||||
|
+ "╠════════════════════════════════════════╣\n"
|
||||||
|
+ "║ ▸ 1 Listar todos os clientes ║\n"
|
||||||
|
+ "║ ▸ 2 Procurar cliente ║\n"
|
||||||
|
+ "║ ▸ 3 Editar dados de cliente ║\n"
|
||||||
|
+ "║ ▸ 4 Remover cliente ║\n"
|
||||||
|
+ "║ ▸ 5 Estatísticas do sistema ║\n"
|
||||||
|
+ "║ ▸ 6 Sair ║\n"
|
||||||
|
+ "╚════════════════════════════════════════╝\n");
|
||||||
|
|
||||||
|
int opcao = scanner.nextInt();
|
||||||
|
|
||||||
|
switch (opcao) {
|
||||||
|
case 1:
|
||||||
|
mostrarTodosClientes();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
procurarClienteAdmin();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
editarClienteAdmin();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
removerCliente();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
mostrarEstatisticas();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
sair = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("Opção inválida!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void procurarClienteAdmin() {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.print("Digite o nome, ID ou telefone do cliente: ");
|
||||||
|
String termo = scanner.nextLine();
|
||||||
|
|
||||||
|
String nomeFicheiro = "clientes.txt";
|
||||||
|
|
||||||
|
if (getNumeroLinhasFicheiro(nomeFicheiro) == 0) {
|
||||||
|
System.out.println("Nenhum cliente cadastrado.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] nome = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] idTitular = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] numeroTel = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] email = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] nif = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] saldoTxt = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
|
||||||
|
leExtraiCsvFicheiro(nomeFicheiro, nome, idTitular, numeroTel, email, nif, saldoTxt);
|
||||||
|
|
||||||
|
boolean encontrado = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < nome.length; i++) {
|
||||||
|
if (nome[i].toLowerCase().contains(termo.toLowerCase()) ||
|
||||||
|
idTitular[i].equals(termo) ||
|
||||||
|
numeroTel[i].equals(termo)) {
|
||||||
|
|
||||||
|
System.out.println("\n╔════════════════════════════════════════╗");
|
||||||
|
System.out.println("║ CLIENTE ENCONTRADO ║");
|
||||||
|
System.out.println("╠════════════════════════════════════════╣");
|
||||||
|
System.out.printf("║ Nome: %-25s ║\n", nome[i]);
|
||||||
|
System.out.printf("║ ID: %-25s ║\n", idTitular[i]);
|
||||||
|
System.out.printf("║ Telefone: %-25s ║\n", numeroTel[i]);
|
||||||
|
System.out.printf("║ Email: %-25s ║\n", email[i]);
|
||||||
|
System.out.printf("║ NIF: %-25s ║\n", nif[i]);
|
||||||
|
System.out.printf("║ Saldo: €%-24s ║\n", saldoTxt[i]);
|
||||||
|
System.out.println("╚════════════════════════════════════════╝\n");
|
||||||
|
encontrado = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!encontrado) {
|
||||||
|
System.out.println("❌ Cliente não encontrado.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void editarClienteAdmin() {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.print("Digite o ID do cliente que deseja editar: ");
|
||||||
|
String id = scanner.nextLine();
|
||||||
|
|
||||||
|
String[] dadosCliente = procurarClientePorId(id);
|
||||||
|
|
||||||
|
if (dadosCliente == null) {
|
||||||
|
System.out.println("❌ Cliente não encontrado!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("\n--- Editando cliente: " + dadosCliente[0] + " ---");
|
||||||
|
|
||||||
|
System.out.print("Novo nome (atual: " + dadosCliente[0] + "): ");
|
||||||
|
String novoNome = scanner.nextLine();
|
||||||
|
if (!novoNome.isEmpty()) dadosCliente[0] = novoNome;
|
||||||
|
|
||||||
|
System.out.print("Novo telefone (atual: " + dadosCliente[2] + "): ");
|
||||||
|
String novoTelefone = scanner.nextLine();
|
||||||
|
if (!novoTelefone.isEmpty()) {
|
||||||
|
if (novoTelefone.length() == 9 && novoTelefone.matches("\\d+")) {
|
||||||
|
if (!telefoneJaExiste(novoTelefone) || dadosCliente[2].equals(novoTelefone)) {
|
||||||
|
dadosCliente[2] = novoTelefone;
|
||||||
|
} else {
|
||||||
|
System.out.println("❌ Telefone já existe! Mantido o original.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("❌ Telefone inválido! Mantido o original.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.print("Novo email (atual: " + dadosCliente[3] + "): ");
|
||||||
|
String novoEmail = scanner.nextLine();
|
||||||
|
if (!novoEmail.isEmpty() && verificarEmail(novoEmail)) {
|
||||||
|
dadosCliente[3] = novoEmail;
|
||||||
|
} else if (!novoEmail.isEmpty()) {
|
||||||
|
System.out.println("❌ Email inválido! Mantido o original.");
|
||||||
|
}
|
||||||
|
|
||||||
|
atualizarClienteCompleto(dadosCliente);
|
||||||
|
System.out.println("✅ Cliente atualizado com sucesso!");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void removerCliente() {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.print("Digite o ID do cliente que deseja remover: ");
|
||||||
|
String id = scanner.nextLine();
|
||||||
|
|
||||||
|
String nomeFicheiro = "clientes.txt";
|
||||||
|
|
||||||
|
if (getNumeroLinhasFicheiro(nomeFicheiro) == 0) {
|
||||||
|
System.out.println("Nenhum cliente cadastrado.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] nome = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] idTitular = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] numeroTel = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] email = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] nif = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] saldoTxt = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
|
||||||
|
leExtraiCsvFicheiro(nomeFicheiro, nome, idTitular, numeroTel, email, nif, saldoTxt);
|
||||||
|
|
||||||
|
int indiceRemover = -1;
|
||||||
|
for (int i = 0; i < idTitular.length; i++) {
|
||||||
|
if (idTitular[i].equals(id)) {
|
||||||
|
indiceRemover = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (indiceRemover == -1) {
|
||||||
|
System.out.println("Cliente não encontrado!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.print("Tem certeza que deseja remover o cliente " + nome[indiceRemover] + "? (s/n): ");
|
||||||
|
String confirmacao = scanner.nextLine();
|
||||||
|
|
||||||
|
if (confirmacao.equalsIgnoreCase("s")) {
|
||||||
|
StringBuilder novoConteudo = new StringBuilder();
|
||||||
|
for (int i = 0; i < nome.length; i++) {
|
||||||
|
if (i != indiceRemover) {
|
||||||
|
novoConteudo.append(nome[i]).append(",")
|
||||||
|
.append(idTitular[i]).append(",")
|
||||||
|
.append(numeroTel[i]).append(",")
|
||||||
|
.append(email[i]).append(",")
|
||||||
|
.append(nif[i]).append(",")
|
||||||
|
.append(saldoTxt[i]).append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
escreveNoFicheiro(novoConteudo.toString(), nomeFicheiro);
|
||||||
|
System.out.println("Cliente removido com sucesso!");
|
||||||
|
} else {
|
||||||
|
System.out.println("Operação cancelada.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void mostrarEstatisticas() {
|
||||||
|
String nomeFicheiro = "clientes.txt";
|
||||||
|
int numClientes = getNumeroLinhasFicheiro(nomeFicheiro);
|
||||||
|
|
||||||
|
if (numClientes == 0) {
|
||||||
|
System.out.println("Nenhum cliente cadastrado.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] nome = new String[numClientes];
|
||||||
|
String[] idTitular = new String[numClientes];
|
||||||
|
String[] numeroTel = new String[numClientes];
|
||||||
|
String[] email = new String[numClientes];
|
||||||
|
String[] nif = new String[numClientes];
|
||||||
|
String[] saldoTxt = new String[numClientes];
|
||||||
|
|
||||||
|
leExtraiCsvFicheiro(nomeFicheiro, nome, idTitular, numeroTel, email, nif, saldoTxt);
|
||||||
|
|
||||||
|
double saldoTotal = 0;
|
||||||
|
double saldoMinimo = Double.MAX_VALUE;
|
||||||
|
double saldoMaximo = Double.MIN_VALUE;
|
||||||
|
String clienteSaldoMinimo = "";
|
||||||
|
String clienteSaldoMaximo = "";
|
||||||
|
|
||||||
|
for (int i = 0; i < numClientes; i++) {
|
||||||
|
double saldo = Double.parseDouble(saldoTxt[i]);
|
||||||
|
saldoTotal += saldo;
|
||||||
|
|
||||||
|
if (saldo < saldoMinimo) {
|
||||||
|
saldoMinimo = saldo;
|
||||||
|
clienteSaldoMinimo = nome[i];
|
||||||
|
}
|
||||||
|
if (saldo > saldoMaximo) {
|
||||||
|
saldoMaximo = saldo;
|
||||||
|
clienteSaldoMaximo = nome[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double saldoMedio = saldoTotal / numClientes;
|
||||||
|
|
||||||
|
System.out.println("\n╔════════════════════════════════════════════════════════════════╗");
|
||||||
|
System.out.println("║ ESTATÍSTICAS DO SISTEMA ║");
|
||||||
|
System.out.println("╠════════════════════════════════════════════════════════════════╣");
|
||||||
|
System.out.printf("║ %-58s ║\n", "Total de clientes: " + numClientes);
|
||||||
|
System.out.printf("║ %-58s ║\n", String.format("Saldo total do banco: €%.2f", saldoTotal));
|
||||||
|
System.out.printf("║ %-58s ║\n", String.format("Saldo médio por cliente: €%.2f", saldoMedio));
|
||||||
|
System.out.printf("║ %-58s ║\n", String.format("Cliente com maior saldo: %s (€%.2f)", clienteSaldoMaximo, saldoMaximo));
|
||||||
|
System.out.printf("║ %-58s ║\n", String.format("Cliente com menor saldo: %s (€%.2f)", clienteSaldoMinimo, saldoMinimo));
|
||||||
|
System.out.println("╚════════════════════════════════════════════════════════════════╝\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void atualizarClienteCompleto(String[] dados) {
|
||||||
|
String nomeFicheiro = "clientes.txt";
|
||||||
|
|
||||||
|
String[] nome = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] idTitular = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] numeroTel = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] email = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] nif = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] saldoTxt = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
|
||||||
|
leExtraiCsvFicheiro(nomeFicheiro, nome, idTitular, numeroTel, email, nif, saldoTxt);
|
||||||
|
|
||||||
|
StringBuilder novoConteudo = new StringBuilder();
|
||||||
|
for (int i = 0; i < idTitular.length; i++) {
|
||||||
|
if (idTitular[i].equals(dados[1])) {
|
||||||
|
novoConteudo.append(dados[0]).append(",")
|
||||||
|
.append(dados[1]).append(",")
|
||||||
|
.append(dados[2]).append(",")
|
||||||
|
.append(dados[3]).append(",")
|
||||||
|
.append(dados[4]).append(",")
|
||||||
|
.append(dados[5]).append("\n");
|
||||||
|
} else {
|
||||||
|
novoConteudo.append(nome[i]).append(",")
|
||||||
|
.append(idTitular[i]).append(",")
|
||||||
|
.append(numeroTel[i]).append(",")
|
||||||
|
.append(email[i]).append(",")
|
||||||
|
.append(nif[i]).append(",")
|
||||||
|
.append(saldoTxt[i]).append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
escreveNoFicheiro(novoConteudo.toString(), nomeFicheiro);
|
||||||
|
}
|
||||||
public static boolean verificarNIF(String nif) {
|
public static boolean verificarNIF(String nif) {
|
||||||
// Verificar se tem 9 dígitos
|
// Verificar se tem 9 dígitos
|
||||||
if (!nif.matches("\\d{9}")) {
|
if (!nif.matches("\\d{9}")) {
|
||||||
@@ -413,70 +894,330 @@ public static void editarDinheiroCliente() {
|
|||||||
}
|
}
|
||||||
return vrSaldo;
|
return vrSaldo;
|
||||||
}
|
}
|
||||||
|
private static String gerarID() {
|
||||||
|
boolean idFeito = true;
|
||||||
|
while(true){
|
||||||
|
String CARACTERES = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
||||||
|
"abcdefghijklmnopqrstuvwxyz" +
|
||||||
|
"0123456789";
|
||||||
|
SecureRandom random = new SecureRandom();
|
||||||
|
|
||||||
|
StringBuilder idNum = new StringBuilder(6);
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
int indice = random.nextInt(CARACTERES.length());
|
||||||
|
idNum.append(CARACTERES.charAt(indice));
|
||||||
|
}
|
||||||
|
// ver se id já existe
|
||||||
|
String idTxt = idNum.toString();
|
||||||
|
if(!idJaExiste(idTxt)){
|
||||||
|
return idTxt;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static boolean nifJaExiste(String nif) {
|
||||||
|
String nomeFicheiro = "clientes.txt";
|
||||||
|
|
||||||
|
// 1. Começamos assumindo que NÃO existe
|
||||||
|
try (BufferedReader reader = new BufferedReader(new FileReader(nomeFicheiro))) {
|
||||||
|
String linha;
|
||||||
|
while ((linha = reader.readLine()) != null) {
|
||||||
|
String[] campos = linha.split(",");
|
||||||
|
|
||||||
|
// 2. Verificamos se a linha tem dados e se o NIF coincide
|
||||||
|
if (campos.length > 0 && campos[0].trim().equals(nif.trim())) {
|
||||||
|
return true; // Encontrou? Retorna imediatamente e fecha o reader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Opcional: imprimir erro para saber por que a leitura falhou
|
||||||
|
System.err.println("Erro ao ler o ficheiro: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // Se percorreu tudo e não achou, retorna false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean idJaExiste(String idTxt) {
|
||||||
|
String nomeFicheiro = "clientes.txt";
|
||||||
|
|
||||||
|
if (getNumeroLinhasFicheiro(nomeFicheiro) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] ids = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp1 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp2 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp3 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp4 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp5 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
|
||||||
|
leExtraiCsvFicheiro(nomeFicheiro, temp1, ids, temp2, temp3, temp4, temp5);
|
||||||
|
|
||||||
|
for (String idExistente : ids) {
|
||||||
|
if (idExistente.equals(idTxt)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean telefoneJaExiste(String telefone) {
|
||||||
|
String nomeFicheiro = "clientes.txt";
|
||||||
|
|
||||||
|
if (getNumeroLinhasFicheiro(nomeFicheiro) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] telefones = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp1 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp2 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp3 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp4 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
String[] temp5 = new String[getNumeroLinhasFicheiro(nomeFicheiro)];
|
||||||
|
|
||||||
|
leExtraiCsvFicheiro(nomeFicheiro, temp1, temp2, telefones, temp3, temp4, temp5);
|
||||||
|
|
||||||
|
for (String telefoneExistente : telefones) {
|
||||||
|
if (telefoneExistente.equals(telefone)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void adicionarNovoCliente() {
|
private static void adicionarNovoCliente() {
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
System.out.print("\n"
|
System.out.print("\n╔════════════════════════════════════════\n");
|
||||||
+ "╔════════════════════════════════════════\n"
|
System.out.print("║ Introduza o nome: ");
|
||||||
+ "║Introduza o nome: ");
|
String nome = scanner.nextLine();
|
||||||
String nome = scanner.next();
|
|
||||||
System.out.print("╠════════════════════════════════════════\n");
|
|
||||||
System.out.print("║Introduza o ID: ");
|
|
||||||
String idTitular = scanner.next();
|
|
||||||
System.out.print("╠════════════════════════════════════════\n");
|
|
||||||
|
|
||||||
String nif;
|
String idTitular = gerarID();
|
||||||
System.out.print("║Introduza NIF: ");
|
|
||||||
nif = scanner.next();
|
|
||||||
|
|
||||||
while(!verificarNIF(nif)) {
|
while (idJaExiste(idTitular)) {
|
||||||
System.out.println("║NIF inválido!\n"
|
idTitular = gerarID();
|
||||||
+ "║Introduza NIF novamente:");
|
}
|
||||||
nif = scanner.next();
|
|
||||||
System.out.print("╠════════════════════════════════════════\n");
|
|
||||||
}
|
|
||||||
System.out.print("╠════════════════════════════════════════\n");
|
|
||||||
System.out.print("║Introduza número: ");
|
|
||||||
String NumeroTel = scanner.next();
|
|
||||||
System.out.print("╠════════════════════════════════════════\n");
|
|
||||||
|
|
||||||
String email;
|
System.out.println("║ ID gerado: " + idTitular);
|
||||||
System.out.print("║Introduza email: ");
|
|
||||||
email = scanner.next();
|
|
||||||
|
|
||||||
while(!verificarEmail(email)) {
|
String nif;
|
||||||
System.out.println("║Email inválido!");
|
do {
|
||||||
System.out.println("║Introduza email novamente:");
|
System.out.print("║ Introduza NIF (9 dígitos): ");
|
||||||
email = scanner.next();
|
nif = scanner.nextLine();
|
||||||
System.out.print("╠════════════════════════════════════════\n");
|
|
||||||
|
if (!verificarNIF(nif)) {
|
||||||
|
System.out.println("║ NIF inválido! Deve ter 9 dígitos válidos.");
|
||||||
|
} else if (nifJaExiste(nif)) {
|
||||||
|
System.out.println("║ Este NIF já está cadastrado!");
|
||||||
|
System.out.println("║ Por favor, insira um NIF diferente.");
|
||||||
|
nif = "";
|
||||||
|
}
|
||||||
|
} while (!verificarNIF(nif) || nif.isEmpty());
|
||||||
|
|
||||||
|
String telefone;
|
||||||
|
do {
|
||||||
|
System.out.print("║ Introduza telefone (9 dígitos): ");
|
||||||
|
telefone = scanner.nextLine();
|
||||||
|
|
||||||
|
if (telefone.length() != 9 || !telefone.matches("\\d+")) {
|
||||||
|
System.out.println("║ Telefone inválido! Deve ter 9 dígitos.");
|
||||||
|
} else if (telefoneJaExiste(telefone)) {
|
||||||
|
System.out.println("║ Este telefone já está cadastrado!");
|
||||||
|
System.out.println("║ Por favor, insira um telefone diferente.");
|
||||||
|
telefone = "";
|
||||||
|
}
|
||||||
|
} while (telefone.isEmpty() || telefone.length() != 9 || !telefone.matches("\\d+"));
|
||||||
|
|
||||||
|
String email;
|
||||||
|
do {
|
||||||
|
System.out.print("║ Introduza email: ");
|
||||||
|
email = scanner.nextLine();
|
||||||
|
|
||||||
|
if (!verificarEmail(email)) {
|
||||||
|
System.out.println("║ Email inválido! Deve conter @ e .pt ou .com");
|
||||||
|
}
|
||||||
|
} while (!verificarEmail(email));
|
||||||
|
|
||||||
|
double saldo;
|
||||||
|
do {
|
||||||
|
System.out.print("║ Introduza saldo (mínimo 60€): ");
|
||||||
|
saldo = scanner.nextDouble();
|
||||||
|
scanner.nextLine(); // limpar buffer
|
||||||
|
|
||||||
|
if (saldo < 60) {
|
||||||
|
System.out.println("║ Saldo mínimo insuficiente! Mínimo 60€.");
|
||||||
|
}
|
||||||
|
} while (saldo < 60);
|
||||||
|
|
||||||
}
|
|
||||||
System.out.print("╠════════════════════════════════════════\n");
|
|
||||||
double saldo;
|
|
||||||
System.out.print("║Introduza saldo(Min: 60€): ");
|
|
||||||
saldo = scanner.nextDouble();
|
|
||||||
while(verificarSaldo(saldo)) {
|
|
||||||
System.out.println("║saldo minimo insuficiente");
|
|
||||||
System.out.println("║Introduza saldo novamente:");
|
|
||||||
saldo = scanner.nextDouble();
|
|
||||||
System.out.print("╠════════════════════════════════════════\n");
|
|
||||||
}
|
|
||||||
String saldoTxt = Double.toString(saldo);
|
String saldoTxt = Double.toString(saldo);
|
||||||
|
|
||||||
System.out.println("║Conta criada co sucesso!");
|
System.out.println("║ Conta criada com sucesso!");
|
||||||
System.out.print("╚════════════════════════════════════════\n"
|
System.out.print("╚════════════════════════════════════════\n\n");
|
||||||
+ "\n");
|
|
||||||
String cliente = nome + (",") + idTitular + (",") + nif + (",") + NumeroTel + (",") + email + (",") + saldoTxt + (".");
|
// Formato: nome,id,telefone,email,nif,saldo
|
||||||
|
String cliente = nome + "," + idTitular + "," + telefone + "," + email + "," + nif + "," + saldoTxt + "\n";
|
||||||
adicionaTextoAoFicheiro(cliente, "clientes.txt");
|
adicionaTextoAoFicheiro(cliente, "clientes.txt");
|
||||||
}
|
}
|
||||||
|
// Taxas baseadas no EURO
|
||||||
|
|
||||||
/**
|
static double[] taxas = {
|
||||||
* ****************************************************Moeda****************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
// private static void moeda(){
|
1.00, // EUR
|
||||||
// procurarCliente();
|
|
||||||
//
|
1.09, // USD
|
||||||
// }
|
|
||||||
}
|
169.00, // JPY
|
||||||
|
|
||||||
|
0.86, // GBP
|
||||||
|
|
||||||
|
7.90, // CNY
|
||||||
|
|
||||||
|
1.65, // AUD
|
||||||
|
|
||||||
|
1.50, // CAD
|
||||||
|
|
||||||
|
0.98 // CHF
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Conversão baseada no EURO
|
||||||
|
|
||||||
|
public static double converter(double valor, int origem, int destino) {
|
||||||
|
|
||||||
|
double valorEUR = valor / taxas[origem];
|
||||||
|
|
||||||
|
double resultado = valorEUR * taxas[destino];
|
||||||
|
|
||||||
|
resultado = ((int)(resultado * 100 + 0.50)) / 100.00;
|
||||||
|
|
||||||
|
return resultado;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String simboloMoeda(int moeda) {
|
||||||
|
|
||||||
|
switch (moeda) {
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
|
||||||
|
return "€";
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
|
||||||
|
return "$";
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
|
||||||
|
return "¥";
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
|
||||||
|
return "£";
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
|
||||||
|
return "¥";
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
|
||||||
|
return "A$";
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
|
||||||
|
return "C$";
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
|
||||||
|
return "Fr";
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
return "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void moeda() {
|
||||||
|
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
|
||||||
|
int opcao = 1;
|
||||||
|
|
||||||
|
while (opcao != 0) {
|
||||||
|
|
||||||
|
System.out.println("\n=== MOEDAS DISPONIVEIS === "+ " ⣀⣠⣤⣤⣤⣀⡀");
|
||||||
|
System.out.println("1 - EUR — € — European Union "+ " ⣀⣴⣿⣿⠿⠿⠿⠿⢿⣿⣷⠄");
|
||||||
|
System.out.println("2 - USD — $ — United States "+ " ⢀⣴⣿⠟⠉⠀⠀⠀⠀⠀⠀⠈⠉⠀");
|
||||||
|
System.out.println("3 - JPY — ¥ — Japan "+ " ⣀⣀⣀⣾⣿⣇⣀⣀⣀⣀⣀⣀⣀⣀⠀");
|
||||||
|
System.out.println("4 - GBP — £ — United Kingdom "+ " ⠛⠛⢻⣿⣿⠛⠛⠛⠛⠛⠛⠛⠛⠛⠀");
|
||||||
|
System.out.println("5 - CNY — ¥ — China "+ " ⣤⣤⣼⣿⣿⣤⣤⣤⣤⣤⣤⣤⣤⣤⠀");
|
||||||
|
System.out.println("6 - AUD — A$ — Australia "+ " ⠉⠉⠉⢿⣿⣏⠉⠉⠉⠉⠉⠉⠉⠉⠀");
|
||||||
|
System.out.println("7 - CAD — C$ — Canada "+ " ⠈⢻⣿⣦⣀⠀⠀⠀⠀⠀⠀⢀⣀⠀");
|
||||||
|
System.out.println("8 - CHF — Fr — Switzerland "+ " ⠉⠻⣿⣿⣶⣶⣶⣶⣿⣿⡿⠃⠀\n"
|
||||||
|
+ " ⠉⠙⠛⠛⠛⠉⠁⠀⠀⠀" );
|
||||||
|
|
||||||
|
int origem;
|
||||||
|
while (true) {
|
||||||
|
System.out.print("\nEscolha a moeda a converter: ");
|
||||||
|
origem = sc.nextInt();
|
||||||
|
if (origem >= 1 && origem <= 8) break;
|
||||||
|
|
||||||
|
System.out.println("Opção invalida. Insira novamente.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int destino;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
System.out.print("Escolhe a moeda pretendida: ");
|
||||||
|
|
||||||
|
destino = sc.nextInt();
|
||||||
|
|
||||||
|
if (destino >= 1 && destino <= 8) break;
|
||||||
|
|
||||||
|
System.out.println("Opção invalida. Insira novamente.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.print("Valor a converter: ");
|
||||||
|
|
||||||
|
double valor = sc.nextDouble();
|
||||||
|
|
||||||
|
double resultado = converter(valor, origem - 1, destino - 1);
|
||||||
|
|
||||||
|
System.out.println("\n=== RESULTADO ===");
|
||||||
|
|
||||||
|
System.out.println(valor + " " +
|
||||||
|
|
||||||
|
simboloMoeda(origem) +
|
||||||
|
|
||||||
|
" = " +
|
||||||
|
|
||||||
|
resultado +
|
||||||
|
|
||||||
|
" " +
|
||||||
|
|
||||||
|
simboloMoeda(destino));
|
||||||
|
|
||||||
|
System.out.println("\n1 - Nova conversão");
|
||||||
|
|
||||||
|
System.out.println("0 - Sair");
|
||||||
|
|
||||||
|
System.out.print("Opção: ");
|
||||||
|
|
||||||
|
opcao = sc.nextInt();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Programa terminado.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user