Advertisement
Guest User

classe

a guest
Sep 16th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package avaliação;
  7.  
  8. import java.text.DecimalFormat;
  9. import java.text.NumberFormat;
  10.  
  11. /**
  12.  *
  13.  * @author Renan Fiedler e Lucas Eduardo
  14.  */
  15. public class ImpostoRenda {
  16.  
  17.     private String Nome;
  18.     private double Salario;
  19.  
  20.     public String getNome() {
  21.         return Nome;
  22.     }
  23.  
  24.     public void setNome(String Nome) {
  25.         this.Nome = Nome;
  26.     }
  27.  
  28.     public double getSalario() {
  29.         return Salario;
  30.     }
  31.  
  32.     public void setSalario(double Salario) {
  33.         this.Salario = Salario;
  34.     }
  35.  
  36.     public byte getFaixa() {
  37.         if (this.Salario >= 4087.66) {
  38.             return 5;
  39.         } else if (this.Salario >= 3271.39) {
  40.             return 4;
  41.         } else if (this.Salario >= 2453.51) {
  42.             return 3;
  43.         } else if (this.Salario >= 1637.12) {
  44.             return 2;
  45.         }
  46.         return 1;
  47.     }
  48.  
  49.     public double calcularImposto() {
  50.         double total = 0;
  51.        
  52.         if (this.Salario >= 1637.12) {
  53.             if (this.Salario < 2454.50) {
  54.                 total += (this.Salario - 1637.11) * 0.075;
  55.             } else {
  56.                 total += (2453.50 - 1637.11) * 0.075;
  57.             }
  58.         }
  59.         if (this.Salario >= 2453.51) {
  60.             if (this.Salario < 3271.38) {
  61.                 total += (this.Salario - 2453.50) * 0.15;
  62.             } else {
  63.                 total += (3271.38 - 2453.50) * 0.15;
  64.             }
  65.         }
  66.         if (this.Salario >= 3271.39) {
  67.             if (this.Salario < 4087.65) {
  68.                 total += (this.Salario - 3271.38) * 0.225;
  69.             } else {
  70.                 total += (4087.65 - 3271.38) * 0.225;
  71.             }
  72.         }
  73.         if (this.Salario >= 4087.65) {
  74.             total += (this.Salario - 4087.64) * 0.275;
  75.         }
  76.  
  77.         return total;
  78.     }
  79.  
  80.     @Override
  81.     public String toString() {
  82.         NumberFormat format = new DecimalFormat("0.00");
  83.         return "O salario de " + this.Nome + ", cujo valor eh de R$ " + this.Salario + " enquadra-se na " + this.getFaixa() + "ª faixa e o valor devido eh de R$ " + format.format(this.calcularImposto()) + ".";
  84.     }
  85.  
  86.    
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement