ASIGNATURA: programación IV
SECCION: 01
TEMA:
TAREA FACELETS 2
ALUMNO CARNET
Guzmán Arenívar Juan Carlos 29-4542-2012
Asignatura : PROGRAMACIÓN IV
Profesor : ING. HUGO JOEL ORTIZ
Actividad : DESARROLLO DE EJERCICIO CON FACELETS
Ciclo : 01-2021
Sección : 01
Crear un menú donde el usuario pueda seleccionar que ejercicio desea ejecutar, para cada
opción cambiar el enunciado del problema en la parte de descripción.
Ejercicio 1. Calcular el aumento de salario que recibirá un empleado al finalizar el
periodo, el calculo se realiza en base al tiempo de servicio en la empresa y se utiliza
Ejercicio 3. Calcular el salario neto que recibirá el empleado si a este se la hace los
siguiente descuentos:
Hojadeestilo.css
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : Oct 27, 2021, 10:42:03 AM
Author : jcgar
*/
*{
box-sizing: border-box;
}
body {
font-family: Arial;
padding: 10px;
background: black;
}
.header {
padding: 30px;
text-align: center;
background: black;
}
.header h1 {
font-size: 50px;
}
index.xhtml
</ui:define>
</ui:composition>
faces-config.xml
<managed-bean>
<managed-bean-name>Ejercicio_1</managed-bean-name>
<managed-bean-class>Ejercicio_1</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>Ejercicio_2</managed-bean-name>
<managed-bean-class>Ejercicio_2</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>Ejercicio_3</managed-bean-name>
<managed-bean-class>Ejercicio_3</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>Ejercicio_4</managed-bean-name>
<managed-bean-class>Ejercicio_4</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
template.xhtml
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jcgar
*/
public class Ejercicio_1 {
public Ejercicio_1() {
}
private int tiempo;
private double salario;
private double aumento;
private double neto;
/**
* @return the tiempo
*/
public int getTiempo() {
return tiempo;
}
/**
* @param tiempo the tiempo to set
*/
public void setTiempo(int tiempo) {
this.tiempo = tiempo;
}
/**
* @return the salario
*/
public double getSalario() {
return salario;
}
/**
* @param salario the salario to set
*/public void setSalario(double salario) {
this.salario = salario;
}
/**
* @return the aumento
*/
public double getAumento() {
this.calcular_aumento();
return aumento;
}
/**
* @param aumento the aumento to set
*/
public void setAumento(double aumento) {
this.aumento = aumento;
}
/**
* @return the neto
*/
public double getNeto() {
return neto;
}
/**
* @param neto the neto to set
*/
public void setNeto(double neto) {
this.neto = neto;
}
public int calcular_porcentaje(){int porc=0;
if(this.tiempo>=0 && this.tiempo<=5)
{
porc=10;
}
else if(this.tiempo>=6 && this.tiempo<=10)
{
porc=20;
}
else if(this.tiempo>=11)
{
porc=30;
}
return porc;
}
public void calcular_aumento(){
this.aumento=this.salario*calcular_porcentaje()/100;
this.neto=this.salario+this.aumento;
}
}
Ejercicio_1.xhtml
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jcgar
*/
public class Ejercicio_2 {
public Ejercicio_2() {
}
private double compra;
private double descuento;
private double neto;
/**
* @return the compra
*/
public double getCompra() {
return compra;
}
/**
* @param compra the compra to set
*/
public void setCompra(double compra) {
this.compra = compra;
}
/**
* @return the descuento
*/
public double getDescuento() {
calcular_descuento();
return descuento;
}
/**
* @param descuento the descuento to set
*/
public void setDescuento(double descuento) {
this.descuento = descuento;}
/**
* @return the neto
*/
public double getNeto() {
return neto;
}
/**
* @param neto the neto to set
*/
public void setNeto(double neto) {
this.neto = neto;
}
public int calcular_porcentaje(){
int porc=0;
if(this.compra>=0.01 && this.compra<=1000.00)
{
porc=10;
}
else if(this.compra>=1000.01 && this.compra<=3000.00)
{
porc=20;
}
else if(this.compra>=3000.01)
{
porc=30;
}
return porc;
}
public void calcular_descuento(){
this.descuento=this.compra*calcular_porcentaje()/100;
this.neto=this.compra-this.descuento;
}
}
Ejercicio_2.xhtml
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jcgar
*/
public class Ejercicio_3 {
public Ejercicio_3() {
}
private double salario;
private double descuento;
private double neto;
private double totaldescuento;
/**
* @return the salario
*/
public double getSalario() {
return salario;
}
/**
* @param salario the salario to set
*/
public void setSalario(double salario) {
this.salario = salario;
}
/**
* @return the decuento
*/
public double getDescuento() {
calcular_descuento();
return descuento;
}
/**
* @param descuento the descuento to set*/
public void setDescuento(double descuento) {
this.descuento = descuento;
}
/**
* @return the totaldecuento
*/
public double gettotalDescuento() {
calcular_totaldescuento();
return totaldescuento;
}
/**
* @param totaldescuento the totaldescuento to set*/
public void settotalDescuento(double totaldescuento) {
this.totaldescuento = totaldescuento;
}
/**
* @return the neto
*/
public double getNeto() {
return neto;
}
/**
* @param neto the neto to set
*/
public void setNeto(double neto) {
this.neto = neto;
}
public double ISSS()
{
double isss=0;
if(this.salario>=657.25)
{
isss=this.salario*0.03;
}
return isss;
}
public double Renta()
{
double renta=0;
if(this.salario>=857.15)
{renta=this.salario*0.10;
}
return renta;
}
public double AFP()
{
double afp=0;
if(this.salario>=450.00)
{
afp=this.salario*0.05;
}
return afp;
}
public double Seguro()
{
double seguro=0;
if(this.salario<1000)
{
seguro=this.salario*0.04;
}
else
{
seguro=this.salario*0.06;
}
return seguro;
}
public double calcular_descuento(){
this.descuento=ISSS()+Renta()+AFP()+Seguro();
this.neto=this.salario-this.descuento;
return this.neto;
}
public double calcular_totaldescuento(){
this.totaldescuento=ISSS()+Renta()+AFP()+Seguro();
return this.totaldescuento;
}
}
Ejercicio_3.xhtml
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jcgar
*/
public class Ejercicio_4 {
public Ejercicio_4() {
}
private int cant;
private double precio;
private double descuento;
private double neto;
/**
* @return the cant
*/
public int getCant() {
return cant;
}
/**
* @param cant the cant to set
*/
public void setCant(int cant) {
this.cant = cant;
}
/**
* @return the precio
*/
public double getPrecio() {
return precio;
}
/**
* @param precio the precio to set
*/public void setPrecio(double precio) {
this.precio = precio;
}
/**
* @return the descuento
*/
public double getDescuento() {
calcular_descuento();
return descuento;
}
/**
* @param descuento the descuento to set
*/
public void setDescuento(double descuento) {
this.descuento = descuento;
}
/**
* @return the neto
*/
public double getNeto() {
return neto;
}
/**
* @param neto the neto to set
*/
public void setNeto(double neto) {
this.neto = neto;
}
public int calcular_porcentaje(){int porc=0;
if(this.cant>=1 && this.cant<=5)
{
porc=10;
}
else if(this.cant>=6 && this.cant<=10)
{
porc=20;
}
else if(this.cant>=11 && this.cant<=15)
{
porc=30;
}
else if(this.cant>=16 && this.cant<=20)
{
porc=40;
}
else if(this.cant>=21)
{
porc=50;
}
return porc;
}
public double Costo(){
double costo=this.cant*this.precio;
return costo;
}
public void calcular_descuento(){
this.descuento=Costo()*calcular_porcentaje()/100;
this.neto=this.Costo()-this.descuento;
}
}
Ejercicio_4.xhtml
index.xhtml
CODIGO SERVIDOR
<? version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="CSS/Hojadeestilo.css" />
</head>
<body>
<div class="header">
<h1>
Ejercicios con Java Server Faces
</h1>
<p></p>
</div>
<div class="topnav">
<a
href="/Desarrollo_de_ejercicios_con_facelets/faces/Ejercicio_1.xhtml">Ejercicio
1</a>
<a
href="/Desarrollo_de_ejercicios_con_facelets/faces/Ejercicio_2.xhtml">Ejercicio
2</a>
<a
href="/Desarrollo_de_ejercicios_con_facelets/faces/Ejercicio_3.xhtml">Ejercicio
3</a>
<a
href="/Desarrollo_de_ejercicios_con_facelets/faces/Ejercicio_4.xhtml">Ejercicio
4</a>
<a href="/Desarrollo_de_ejercicios_con_facelets/faces/index.xhtml"
style="float:right">INICIO</a>
</div>
<div class="row">
<div class="leftcolumn">
<div class="card"></div>
</div>
<div class="rightcolumn">
<div class="card">
<h2>
Descripcion
</h2>
<p>
Tarea del uso de facelets Crear un menú donde el usuario pueda
seleccionar que ejercicio desea ejecutar, para cada opción
cambiar el enunciado del problema en la parte de descripción.
</p>
</div>
</div>
</div>
<ul id="javax_faces_developmentstage_messages" title="Project
Stage[Development]: Unhandled Messages"></ul>
</body>
</html>
Ejercicio_1.xhtml
CODIGO SERVIDOR
Estructura de proyecto