Está en la página 1de 45

FACULTAD DE INFORMÁTICA

ESCUELA DE CIENCIAS APLICADAS “ING. JULIO CÉSAR ORANTES”

ASIGNATURA: programación IV

CATEDRATICO: Ing. Hugo Joel Ortiz Saldaña

SECCION: 01

TEMA:
TAREA FACELETS 2

ALUMNO CARNET
Guzmán Arenívar Juan Carlos 29-4542-2012

San Salvador, 31 de octubre de 2021


Contenido de la actividad

Asignatura : PROGRAMACIÓN IV
Profesor : ING. HUGO JOEL ORTIZ
Actividad : DESARROLLO DE EJERCICIO CON FACELETS
Ciclo : 01-2021
Sección : 01

Título del Trabajo: Desarrollar los siguientes ejercicios utilizando facelets


Generalidades de la tarea:
Actividad individual evaluada para la Cuarta Evaluación
Fecha de entrega el 31 de oct. de 21
Indicaciones :

El presente trabajo es de carácter INDIVIDUAL , en el cual se le solicita lo siguiente

crear un documento en formato pdf que contenga lo siguiente:


1. Portada
2. código de Facelets y clases
3. Captura de pantalla de la salida
4. código generado por el servidor
5. Script de la base de datos creada.

Al documento colocarle el siguiente nombre: primerapellido_Nombre_tareafacelets2.pdf,


donde el primerapellido corresponde al su primer apellido y Nombre corresponde a su
primer nombre:
ejemplo: Juan_perez_tareafacelets2.pdf

Realizar los Ejercicios siguientes de forma ordenada, en un solo proyecto utilizando


la tecnología JavaServer Faces.

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

El salario y años deberán ser leídos y la información a mostrar será la siguiente:


salario del empleado
porcentaje del aumento
el aumento que recibirá
nuevo salario

Ejercicio 2. Calcular el descuento que se le va aplicar a los clientes es sus compras, el


descuento a aplicar sera de la siguiente manera.

La compra deberá ser leída y la información a mostrar será la siguiente.


Compra realizada
porcentaje a descontar
Valor a Descontar
Tota a Pagar

Ejercicio 3. Calcular el salario neto que recibirá el empleado si a este se la hace los
siguiente descuentos:

La información a mostrar es la siguiente :


Sueldo
descuento de ISSS
Descuento de Renta
Descuento de AFP
Descuento de Seguro
Total de Descuentos
Sueldo Neto

Ejercicio 4. Calcular el valor a pagar por un cliente, si a este se le hacen un descuento de a


cuerdo a la cantidad de artículos que compre, para calcular el descuento

La información a mostrar es la siguiente :


Cantidad de Artículos
Cantidad Comprada
Porcentaje de Descuento
Descuento
Total a Pagar
DESARROLLO

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

<?xml version='1.0' encoding='UTF-8' ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/WEB-INF/TEMPLATE/template.xhtml">
<ui:define name="Descrip">
<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>
</ui:define>
<ui:define name="content">

</ui:define>
</ui:composition>
faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>


<faces-config version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">

<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

<?xml version='1.0' encoding='UTF-8' ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<link rel="stylesheet" href="CSS/Hojadeestilo.css" />
</head>
<body>
<div class="header">
<h1>Ejercicios con Java Server Faces</h1>
<p></p>
</div>
<ui:include src="/WEB-INF/TEMPLATE/menu.xhtml" />
<div class="row">
<div class="leftcolumn">
<div class="card"><ui:insert name="content" /></div>
</div>
<div class="rightcolumn">
<div class="card">
<h2>Descripcion</h2>
<ui:insert name="Descrip" />
</div>
</div>
</div>
</body>
</html>
Ejercicio_1.java

/*
* 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

<?xml version='1.0' encoding='UTF-8' ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/WEB-INF/TEMPLATE/template.xhtml">
<ui:define name="Descrip">
<p>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</p>
</ui:define>
<ui:define name="content">
<h:form>
<p>Ejercicio aumento salarial</p>
<table>
<tr>
<td><h:outputText value="Salario del empleado: " /></td>
<td>
<h:inputText id="Salario" value="#{Ejercicio_1.salario}" required="true">
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"/>
<f:validateDoubleRange minimum="0.00" maximum="9999999.00"/>
</h:inputText>
<h:message for="Salario" styleClass="colores1" showSummary="true"
showDetail="false"/>
</td>
</tr>
<tr>
<td><h:outputText value="Años laborando en la empresa: " /></td>
<td>
<h:inputText id="Tiempo" value="#{Ejercicio_1.tiempo}" required="true">
<f:convertNumber maxIntegerDigits="3"/><f:validateLongRange minimum="0"
maximum="60"/>
</h:inputText>
<h:message for="Tiempo" styleClass="colores1" showSummary="true"
showDetail="false"/>
</td>
</tr>
<tr align="center">
<td colspan="2"><h:commandButton value="Calcular"
action="Ejercicio_1.xhtml"/></td>
</tr>
<c:if test="#{Ejercicio_1.salario > 0 }">
<tr>
<td> <h:outputText value="Salario"/> </td>
<td>
<h:outputText value="#{Ejercicio_1.salario}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Porcentaje de aumento:"/> </td>
<td>
<h:outputText value="#{Ejercicio_1.calcular_porcentaje()}%" />
</td>
</tr>
<tr>
<td> <h:outputText value="Aumento que recibirá:"/> </td>
<td>
<h:outputText value="#{Ejercicio_1.aumento}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr><td> <h:outputText value="Nuevo salario:"/> </td>
<td>
<h:outputText value="#{Ejercicio_1.neto}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
</c:if>
</table>
</h:form>
</ui:define>
</ui:composition>
Ejercicio_2.java

/*
* 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

<?xml version='1.0' encoding='UTF-8' ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/WEB-INF/TEMPLATE/template.xhtml">
<ui:define name="Descrip">
<p>Calcular el descuento que se le va aplicar a los clientes es sus compras.</p>
</ui:define>
<ui:define name="content">
<h:form>
<p>Ingrese Compra realizada</p>
<table>
<tr>
<td><h:outputText value="Compra: " /></td>
<td>
<h:inputText id="Compra" value="#{Ejercicio_2.compra}" required="true">
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"/>
<f:validateDoubleRange minimum="0.01" maximum="9999999.99"/>
</h:inputText>
<h:message for="Compra" styleClass="colores1" showSummary="true"
showDetail="false"/>
</td>
</tr>
<tr align="center">
<td colspan="2"><h:commandButton value="Calcular"
action="Ejercicio_2.xhtml"/></td>
</tr>
<c:if test="#{Ejercicio_2.compra > 0 }">
<tr>
<td> <h:outputText value="Compra Realizada: "/> </td>
<td><h:outputText value="#{Ejercicio_2.compra}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Porcentaje a descontar:"/> </td>
<td>
<h:outputText value="#{Ejercicio_2.calcular_porcentaje()}%" />
</td>
</tr>
<tr>
<td> <h:outputText value="Valor a descontar:"/> </td>
<td>
<h:outputText value="#{Ejercicio_2.descuento}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Total a pagar:"/> </td>
<td>
<h:outputText value="#{Ejercicio_2.neto}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
</c:if>
</table>
</h:form>
</ui:define>
</ui:composition>
Ejercicio_3.java

/*
* 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

<?xml version='1.0' encoding='UTF-8' ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/WEB-INF/TEMPLATE/template.xhtml">
<ui:define name="Descrip">
<p> Calcular el salario neto que recibirá el empleado</p>
</ui:define>
<ui:define name="content">
<h:form>
<p>Ingrese el salario del empleado</p>
<table>
<tr>
<td><h:outputText value="Sueldo: " /></td>
<td>
<h:inputText id="Salario" value="#{Ejercicio_3.salario}" required="true">
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"/>
<f:validateDoubleRange minimum="0.01" maximum="9999999.99"/>
</h:inputText>
<h:message for="Salario" styleClass="colores1" showSummary="true"
showDetail="false"/>
</td>
</tr>
<tr align="center">
<td colspan="2"><h:commandButton value="Calcular"
action="Ejercicio_3.xhtml"/></td>
</tr>
<c:if test="#{Ejercicio_3.salario > 0 }">
<tr>
<td> <h:outputText value="Salario Base: "/> </td>
<td><h:outputText value="#{Ejercicio_3.salario}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Descuento ISSS:"/> </td>
<td>
<h:outputText value="#{Ejercicio_3.ISSS()}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Descuento Renta:"/> </td>
<td>
<h:outputText value="#{Ejercicio_3.Renta()}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Descuento AFP:"/> </td>
<td>
<h:outputText value="#{Ejercicio_3.AFP()}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Descuento Seguro:"/> </td>
<td><h:outputText value="#{Ejercicio_3.Seguro()}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Total descuentos:"/> </td>
<td>
<h:outputText value="#{Ejercicio_3.calcular_totaldescuento()}" >
<f:convertNumber maxIntegerDigits="9" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Sueldo Neto:"/> </td>
<td>
<h:outputText value="#{Ejercicio_3.calcular_descuento()}" >
<f:convertNumber maxIntegerDigits="9" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
</c:if>
</table>
</h:form>
</ui:define>
</ui:composition>
Ejercicio_4.java

/*
* 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

<?xml version='1.0' encoding='UTF-8' ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/WEB-INF/TEMPLATE/template.xhtml">
<ui:define name="Descrip">
<p> Calcular el valor a pagar por un cliente, si a este se le hacen un descuento de
a cuerdo a la cantidad
de artículos que compre</p>
</ui:define>
<ui:define name="content">
<h:form>
<p>Descuentos de productos</p>
<table>
<tr>
<td><h:outputText value="Cantidad: " /></td>
<td>
<h:inputText id="Cantidad" value="#{Ejercicio_4.cant}" required="true">
<f:convertNumber maxIntegerDigits="3"/>
<f:validateLongRange minimum="1" maximum="200"/>
</h:inputText>
<h:message for="Cantidad" styleClass="colores1" showSummary="true"
showDetail="false"/>
</td>
</tr>
<tr>
<td><h:outputText value="Precio: " /></td>
<td>
<h:inputText id="Precio" value="#{Ejercicio_4.precio}" required="true">
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"/><f:validateDoubleRange minimum="0.00"
maximum="9999999.00"/>
</h:inputText>
<h:message for="Precio" styleClass="colores1" showSummary="true"
showDetail="false"/>
</td>
</tr>
<tr align="center">
<td colspan="2"><h:commandButton value="Calcular"
action="Ejercicio_4.xhtml"/></td>
</tr>
<c:if test="#{Ejercicio_4.cant > 0 }">
<tr>
<td> <h:outputText value="Cantidad de Articulos: "/> </td>
<td>
<h:outputText value="#{Ejercicio_4.cant}" />
</td>
</tr>
<tr>
<td> <h:outputText value="Cantidad comprada: "/> </td>
<td>
<h:outputText value="#{Ejercicio_4.Costo()}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Porcentaje de descuento:"/> </td>
<td>
<h:outputText value="#{Ejercicio_4.calcular_porcentaje()}%" />
</td>
</tr>
<tr>
<td> <h:outputText value="Descuento:"/> </td>
<td>
<h:outputText value="#{Ejercicio_4.descuento}" ><f:convertNumber
maxIntegerDigits="7" minIntegerDigits="1" maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
<tr>
<td> <h:outputText value="Total a Pagar:"/> </td>
<td>
<h:outputText value="#{Ejercicio_4.neto}" >
<f:convertNumber maxIntegerDigits="7" minIntegerDigits="1"
maxFractionDigits="2"
type="currency" currencySymbol="$"/>
</h:outputText>
</td>
</tr>
</c:if>
</table>
</h:form>
</ui:define>
</ui:composition>
CAPTURAS

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

<? 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">
<form id="j_idt4" name="j_idt4" method="post"
action="/Desarrollo_de_ejercicios_con_facelets/faces/Ejercicio_1.xhtml"
enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt4" value="j_idt4" />
<p>
Ejercicio aumento salarial
</p>
<table>
<tr>
<td>Salario del empleado:</td>
<td>
<input id="j_idt4:Salario" type="text" name="j_idt4:Salario" value="0" />
</td>
</tr>
<tr>
<td>Años laborando en la empresa:</td>
<td>
<input id="j_idt4:Tiempo" type="text" name="j_idt4:Tiempo" value="0"
/>
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" name="j_idt4:j_idt14" value="Calcular" />
</td>
</tr>
</table>
<input type="hidden" name="javax.faces.ViewState"
id="j_id1:javax.faces.ViewState:0"
value="7255757844183527608:1105290773003798860" autocomplete="off" />
</form>
</div>
</div>
<div class="rightcolumn">
<div class="card">
<h2>
Descripcion
</h2>
<p>
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
</p>
</div>
</div>
</div>
<ul id="javax_faces_developmentstage_messages" title="Project
Stage[Development]: Unhandled Messages"></ul>
</body>
</html>
Ejercicio_2.xhtml
CODIGO SERVIDOR Ejercicio_2.xhtml

<? 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">
<form id="j_idt4" name="j_idt4" method="post"
action="/Desarrollo_de_ejercicios_con_facelets/faces/Ejercicio_2.xhtml"
enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt4" value="j_idt4" />
<p>
Ingrese Compra realizada
</p>
<table>
<tr>
<td>Compra:</td>
<td>
<input id="j_idt4:Compra" type="text" name="j_idt4:Compra"
value="3.000" />
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" name="j_idt4:j_idt10" value="Calcular" />
</td>
</tr>
<tr>
<td>Compra Realizada:</td>
<td>3.000,00 $</td>
</tr>
<tr>
<td>Porcentaje a descontar:</td>
<td>20%</td>
</tr>
<tr>
<td>Valor a descontar:</td>
<td>600,00 $</td>
</tr>
<tr>
<td>Total a pagar:</td>
<td>2.400,00 $</td>
</tr>
</table>
<input type="hidden" name="javax.faces.ViewState"
id="j_id1:javax.faces.ViewState:0" value="-
7213858490562079112:3033321462805189846" autocomplete="off" />
</form>
</div>
</div>
<div class="rightcolumn">
<div class="card">
<h2>
Descripcion
</h2>
<p>
Calcular el descuento que se le va aplicar a los clientes es sus compras.
</p>
</div>
</div>
</div>
<ul id="javax_faces_developmentstage_messages" title="Project
Stage[Development]: Unhandled Messages"></ul>
</body>
</html>
Ejercicio_3.xhtml
CODIGO SERVIDOR Ejercicio_3.xhtml

<? 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">
<form id="j_idt4" name="j_idt4" method="post"
action="/Desarrollo_de_ejercicios_con_facelets/faces/Ejercicio_3.xhtml"
enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt4" value="j_idt4" />
<p>
Ingrese el salario del empleado
</p>
<table>
<tr>
<td>Sueldo:</td>
<td>
<input id="j_idt4:Salario" type="text" name="j_idt4:Salario"
value="2.500" />
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" name="j_idt4:j_idt10" value="Calcular" />
</td>
</tr>
<tr>
<td>Salario Base:</td>
<td>2.500,00 $</td>
</tr>
<tr>
<td>Descuento ISSS:</td>
<td>75,00 $</td>
</tr>
<tr>
<td>Descuento Renta:</td>
<td>250,00 $</td>
</tr>
<tr>
<td>Descuento AFP:</td>
<td>125,00 $</td>
</tr>
<tr>
<td>Descuento Seguro:</td>
<td>150,00 $</td>
</tr>
<tr>
<td>Total descuentos:</td>
<td>600,00 $</td>
</tr>
<tr>
<td>Sueldo Neto:</td>
<td>1.900,00 $</td>
</tr>
</table>
<input type="hidden" name="javax.faces.ViewState"
id="j_id1:javax.faces.ViewState:0"
value="4790283536822449625:844725984918167983" autocomplete="off" />
</form>
</div>
</div>
<div class="rightcolumn">
<div class="card">
<h2>
Descripcion
</h2>
<p>
Calcular el salario neto que recibirá el empleado
</p>
</div>
</div>
</div>
<ul id="javax_faces_developmentstage_messages" title="Project
Stage[Development]: Unhandled Messages"></ul>
</body>
</html>
Ejercicio_4.xhtml

CODIGO SERVIDOR Ejercicio_4.xhtml


<? 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">
<form id="j_idt4" name="j_idt4" method="post"
action="/Desarrollo_de_ejercicios_con_facelets/faces/Ejercicio_4.xhtml"
enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt4" value="j_idt4" />
<p>
Descuentos de productos
</p>
<table>
<tr>
<td>Cantidad:</td>
<td>
<input id="j_idt4:Cantidad" type="text" name="j_idt4:Cantidad"
value="12" />
</td>
</tr>
<tr>
<td>Precio:</td>
<td>
<input id="j_idt4:Precio" type="text" name="j_idt4:Precio" value="25" />
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" name="j_idt4:j_idt14" value="Calcular" />
</td>
</tr>
<tr>
<td>Cantidad de Articulos:</td>
<td>12</td>
</tr>
<tr>
<td>Cantidad comprada:</td>
<td>300,00 $</td>
</tr>
<tr>
<td>Porcentaje de descuento:</td>
<td>30%</td>
</tr>
<tr>
<td>Descuento:</td>
<td>90,00 $</td>
</tr>
<tr>
<td>Total a Pagar:</td>
<td>210,00 $</td>
</tr>
</table>
<input type="hidden" name="javax.faces.ViewState"
id="j_id1:javax.faces.ViewState:0" value="3528571675187080799:-
1927892644198969942" autocomplete="off" />
</form>
</div>
</div>
<div class="rightcolumn">
<div class="card">
<h2>
Descripcion
</h2>
<p>
Calcular el valor a pagar por un cliente, si a este se le hacen un descuento
de a cuerdo a la cantidad
de artículos que compre
</p>
</div>
</div>
</div>
<ul id="javax_faces_developmentstage_messages" title="Project
Stage[Development]: Unhandled Messages"></ul>
</body>
</html>

Estructura de proyecto

También podría gustarte