Advertisement
Miketo_prog

Tributar

Sep 30th, 2022 (edited)
890
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | Software | 0 0
  1. /**
  2.  *
  3.  * @author Miketo
  4.  */
  5. public class Tributar {
  6.    private static final short MIN_AGE = 16;
  7.    private static final short MIN_SALARY = 1000;
  8.    private static final Scanner sc = new Scanner(System.in);
  9.    
  10.    public static void main(String[] args) {
  11.       System.out.println("Con este programa sabrás si debes tributar.\n");
  12.      
  13.       if( isOlder(readAge()) && isGoodSalary(readSalary()) ){
  14.             System.out.println("SI debes tributar");
  15.             return;
  16.          }
  17.      
  18.       System.out.println("NO necesitas tributar");
  19.    }
  20.    
  21.    private static int readAge(){
  22.       System.out.print("Introduce tu edad: ");
  23.       return sc.nextInt();
  24.    }
  25.    
  26.    private static double readSalary(){
  27.       System.out.print("Introduce tu salario: $");
  28.       return sc.nextDouble();
  29.    }
  30.    
  31.    private static boolean isOlder(int age){
  32.       return age>MIN_AGE;
  33.    }
  34.    
  35.    private static boolean isGoodSalary(double salary){
  36.       return salary>=MIN_SALARY;
  37.    }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement