Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- programa();
- }
- public static void programa(){
- double salario = 0.0;
- try {
- String input = JOptionPane.showInputDialog(null, "Insira o seu salário");
- if(input.contains(",")){
- input = input.replace(",", ".");
- }
- System.out.println(input);
- salario = Double.parseDouble(input);
- if(salario <= 1903.98){
- showResponse("Você está isento");
- } else if(salario <= 2826.65){
- showResponse("Você deve pagar " + ((salario * 0.075) - 142.8));
- } else if(salario <= 3751.05){
- showResponse("Você deve pagar " + ((salario * 0.15) - 354.8));
- } else if(salario <= 4664.68){
- showResponse("Você deve pagar " + ((salario * 0.225) - 636.13));
- } else {
- showResponse("Você deve pagar " + ((salario * 0.275) - 869.36));
- }
- } catch (NumberFormatException err){
- JOptionPane.showMessageDialog(null, "O número inserido é inválido");
- programa();
- }
- }
- public static void showResponse(String response){
- JOptionPane.showMessageDialog(null, response);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement