Skip to content

Instantly share code, notes, and snippets.

@ulissesBR
Last active January 16, 2024 14:30
Show Gist options
  • Save ulissesBR/7e077d719898389f4eae112c92fe32fd to your computer and use it in GitHub Desktop.
Save ulissesBR/7e077d719898389f4eae112c92fe32fd to your computer and use it in GitHub Desktop.
DESAFIO Imposto Java
import java.util.Locale;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Locale.setDefault(Locale.US);
Scanner sc = new Scanner(System.in);
System.out.print("Renda anual com salário: ");
double rendaAnualSalario = sc.nextDouble();
System.out.print("Renda anual com prestação de serviço: ");
double rendaAnualServico = sc.nextDouble();
System.out.print("Renda anual com ganho de capital: ");
double rendaAnualGanhoCapital = sc.nextDouble();
System.out.print("Gastos médicos: ");
double gastosMedicos = sc.nextDouble();
System.out.print("Gastos educacionais: ");
double gastosEducacionais = sc.nextDouble();
// Calculo sobre salario:
double impostoSobreSalario = 0.0;
if(rendaAnualSalario > (3000 * 12) && rendaAnualSalario < (5000 * 12))
{
impostoSobreSalario = (rendaAnualSalario * 0.10);
}
else if(rendaAnualSalario >= (5000 * 12))
{
impostoSobreSalario = (rendaAnualSalario * 0.20);
}
// Calculo sobre prestacao de servicos:
double impostoSobreServicos = 0.0;
if(rendaAnualServico > 0)
{
impostoSobreServicos += rendaAnualServico * 0.15;
}
//Calculo sobre ganho de capital:
double impostoSobreGanhoCapital = 0.0;
if(rendaAnualGanhoCapital > 0)
{
impostoSobreGanhoCapital += rendaAnualGanhoCapital * 0.20;
}
double impostoTotal = impostoSobreSalario + impostoSobreServicos + impostoSobreGanhoCapital;
double gastosDedutiveis = gastosMedicos + gastosEducacionais;
double maximoDedutivel = impostoTotal * 0.30;
double abatimento = 0.0;
if(gastosDedutiveis < maximoDedutivel)
{
abatimento = gastosDedutiveis;
}
else
{
abatimento = maximoDedutivel;
}
System.out.println();
System.out.println("RELATÓRIO DE IMPOSTO DE RENDA");
System.out.println();
System.out.println("CONSOLIDADO DE RENDA:");
System.out.printf("Imposto sobre salário: %.2f%n", impostoSobreSalario);
System.out.printf("Imposto sobre serviços: %.2f%n", impostoSobreServicos);
System.out.printf("Imposto sobre ganho de capital: %.2f%n", impostoSobreGanhoCapital);
System.out.println();
System.out.println("DEDUÇÕES:");
System.out.printf("Máximo dedutível: %.2f%n", maximoDedutivel);
System.out.printf("Gastos dedutíveis: %.2f%n", gastosDedutiveis);
System.out.println();
System.out.println("RESUMO:");
System.out.printf("Imposto bruto total: %.2f%n", impostoTotal);
System.out.printf("Abatimento: %.2f%n", abatimento);
System.out.printf("Imposto devido: %.2f%n", impostoTotal - abatimento);
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment