Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;.
- (define-struct salario-senador (salBase gastRep primSer))
- (define-struct salario-representante (salBase gasolin gastRep primSer))
- (define-struct salario (total retefuente devengado))
- (define emperorPetrosky (make-salario-senador 45000000 300000 8000000))
- (define estebanQuito
- (make-salario-representante
- 30000000
- 3000000
- 20000000
- 5000000))
- ;;Autor: Carlos A Delgado
- ;;Fecha 31 de Julio de 2020
- ;;Contrato: calcular-salario: congresista -> salario
- ;; Ejemplos
- ;; (calcular-salario emperorPetrosky) (make-salario 53300000 6396000 46904000)
- ;; (calcular-salario estebanQuito) (make-salario 58000000 6960000 51040000)
- (define (calcular-salario cong)
- (cond
- [(salario-senador? cong)
- (make-salario
- ;;Salario total
- (calcular-total-senador cong)
- ;;Retefuente
- (* 0.12 (calcular-total-senador cong))
- ;;Devengado
- (* 0.88 (calcular-total-senador cong))
- )]
- [(salario-representante? cong)
- (make-salario
- ;;Salario total
- (calcular-total-representante cong)
- ;;Retefuente
- (* 0.12 (calcular-total-representante cong))
- ;;Devengado
- (* 0.88 (calcular-total-representante cong))
- )]
- [else (error "La estructura cong debe ser senador o representante")]))
- (define (calcular-total-senador cong)
- (+ (salario-senador-salBase cong)
- (salario-senador-gastRep cong)
- (salario-senador-primSer cong)
- ))
- (define (calcular-total-representante cong)
- (+ (salario-representante-salBase cong)
- (salario-representante-gasolin cong)
- (salario-representante-gastRep cong)
- (salario-representante-primSer cong)
- ))
- (check-expect (calcular-salario emperorPetrosky) (make-salario 53300000 6396000 46904000))
- (check-expect (calcular-salario estebanQuito) (make-salario 58000000 6960000 51040000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement