Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class Main {
  4.  
  5.  
  6.     /**
  7.      * @param args the command line arguments
  8.      */
  9.     public static void main(String[] args) {
  10.         programa();
  11.     }
  12.  
  13.     public static void programa(){
  14.  
  15.         double salario = 0.0;
  16.  
  17.         try {
  18.             String input = JOptionPane.showInputDialog(null, "Insira o seu salário");
  19.             if(input.contains(",")){
  20.                 input = input.replace(",", ".");
  21.             }
  22.             System.out.println(input);
  23.             salario = Double.parseDouble(input);
  24.  
  25.             if(salario <= 1903.98){
  26.                 showResponse("Você está isento");
  27.             } else if(salario <= 2826.65){
  28.                 showResponse("Você deve pagar " + ((salario * 0.075) - 142.8));
  29.             } else if(salario <= 3751.05){
  30.                 showResponse("Você deve pagar " + ((salario * 0.15) - 354.8));
  31.             } else if(salario <= 4664.68){
  32.                 showResponse("Você deve pagar " + ((salario * 0.225) - 636.13));
  33.             } else {
  34.                 showResponse("Você deve pagar " + ((salario * 0.275) - 869.36));
  35.             }
  36.         } catch (NumberFormatException err){
  37.             JOptionPane.showMessageDialog(null, "O número inserido é inválido");
  38.             programa();
  39.         }
  40.     }
  41.  
  42.     public static void showResponse(String response){
  43.         JOptionPane.showMessageDialog(null, response);
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement