Advertisement
infosatjr

Untitled

Oct 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.36 KB | None | 0 0
  1.  
  2. import java.util.Random;
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class ContaEspecial {
  7.  
  8.     private String correntista;
  9.     private double saldo;
  10.     private float limite;
  11.  
  12.     public ContaEspecial() {
  13.     }
  14.  
  15.     public float getLimite() {
  16.         return limite;
  17.     }
  18.  
  19.     public void setLimite(float limite) {
  20.         this.limite = limite;
  21.     }
  22.  
  23.     public String getCorrentista() {
  24.         return correntista;
  25.     }
  26.  
  27.     public void setCorrentista(String correntista) {
  28.         this.correntista = correntista;
  29.     }
  30.  
  31.     public double getSaldo() {
  32.         return saldo;
  33.     }
  34.  
  35.     public void setSaldo(double saldo) {
  36.         this.saldo = saldo;
  37.     }
  38.  
  39.     public void valorDisponivel() {
  40.         System.out.println("Valor Disponivel: " + saldo + "\n");
  41.  
  42.     }
  43.  
  44.     public void saque(float retirada) {
  45.         if (saldo >= retirada) {
  46.             saldo -= retirada;
  47.             int saques = 0;
  48.             saques++;
  49.             System.out.println("Sacado: " + retirada);
  50.             System.out.println("Novo saldo: " + saldo + "\n");
  51.         } else {
  52.             System.out.println("Saldo insuficiente. Faça um depósito\n");
  53.         }
  54.  
  55.     }
  56.  
  57. public void exibeMenu() {
  58.  
  59.         System.out.println("\n Escolha a opção desejada");
  60.         System.out.println("1 - Consultar Extrato");
  61.         System.out.println("2 - Sacar");
  62.         System.out.println("3 - Sair\n");
  63.         System.out.print("Opção: ");
  64.  
  65.     }
  66.  
  67.     public void escolheOpcao(int opcao) {
  68.         int saques = 0;
  69.         double valor;
  70.        
  71.         Scanner entrada = new Scanner(System.in);
  72.         Random numero = new Random();
  73.         int conta = 1 + numero.nextInt(9999);
  74.        
  75.         switch (opcao) {
  76.             case 1:
  77.                 valorDisponivel();
  78.                 break;
  79.             case 2:
  80.                 if (saques < 3) {
  81.                     System.out.print("Quanto deseja sacar: ");
  82.                     valor = entrada.nextDouble();
  83.                     saque((float) valor);
  84.                 } else {
  85.                     System.out.println("Limite de saques diários atingidos.\n");
  86.                 }
  87.                 break;
  88.  
  89.             case 3:
  90.                 System.out.println("Sistema encerrado.");
  91.                 break;
  92.  
  93.             default:
  94.                 System.out.println("Opção inválida");
  95.         }
  96.     }
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement