Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package avaliação;
- import java.text.DecimalFormat;
- import java.text.NumberFormat;
- /**
- *
- * @author Renan Fiedler e Lucas Eduardo
- */
- public class ImpostoRenda {
- private String Nome;
- private double Salario;
- public String getNome() {
- return Nome;
- }
- public void setNome(String Nome) {
- this.Nome = Nome;
- }
- public double getSalario() {
- return Salario;
- }
- public void setSalario(double Salario) {
- this.Salario = Salario;
- }
- public byte getFaixa() {
- if (this.Salario >= 4087.66) {
- return 5;
- } else if (this.Salario >= 3271.39) {
- return 4;
- } else if (this.Salario >= 2453.51) {
- return 3;
- } else if (this.Salario >= 1637.12) {
- return 2;
- }
- return 1;
- }
- public double calcularImposto() {
- double total = 0;
- if (this.Salario >= 1637.12) {
- if (this.Salario < 2454.50) {
- total += (this.Salario - 1637.11) * 0.075;
- } else {
- total += (2453.50 - 1637.11) * 0.075;
- }
- }
- if (this.Salario >= 2453.51) {
- if (this.Salario < 3271.38) {
- total += (this.Salario - 2453.50) * 0.15;
- } else {
- total += (3271.38 - 2453.50) * 0.15;
- }
- }
- if (this.Salario >= 3271.39) {
- if (this.Salario < 4087.65) {
- total += (this.Salario - 3271.38) * 0.225;
- } else {
- total += (4087.65 - 3271.38) * 0.225;
- }
- }
- if (this.Salario >= 4087.65) {
- total += (this.Salario - 4087.64) * 0.275;
- }
- return total;
- }
- @Override
- public String toString() {
- NumberFormat format = new DecimalFormat("0.00");
- 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()) + ".";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement