Vous êtes sur la page 1sur 16

FACULTAD: Ingeniería

CARRERA: Ingeniería de Sistemas

PROFESOR: Martin Salcedo Quiñones

CURSO: Programación Visual I

INTEGRANTES: Cristian Roberto Burneo

Moreno Bruce Randy

Reyes Montoro Lorenzo

Mihay Villarreal Alva

Fernando Padilla

Gutiérrez Edilson

Valdez Quiroz

CICLO: III

AÑO: 2019
EJERCICIO N°01

INTERPRETACION:
De acuerdo al formulario, se debe ingresar el precio base de un automóvil, a continuación
se debe calcular lo siguiente: Seleccionar la marca del automóvil que está dentro de un
ComboBox (Toyota, Nissan y Hyunday) adicionalmente los números de puertas que el
cliente desea dentro de otro ComoboBox (3 puertas, 4 puertas, 5 puertas) Dependiendo a
la cantidad de puertas elegidas hay cierto incremento. El número de cuotas no debe ser
mayor a 60.
VALIDACION PARA INGRESAR EL PRECIO DE AUTOMOVIL

VALIDACION PARA SELECCIONAR LA MARCA DEL AUTOMOVIL


VALIDACION PARA SELECCIONAR LA CANTIDAD DE PUERTAS DEL
AUTOMOVIL

VALIDACION PARA ELEGIR EL TIPO DE PAGO


VALIDACION QUE LAS CUOTAS NO SUPEREN A 60

EJECUCION_CREDITO
EJECUCION_CONTADO

PROGRAMACION
package Ejercicios;
import javax.swing.JOptionPane;
public class main extends javax.swing.JFrame {
public main() {
initComponents();
setTitle ("VENTAS DE AUTOMOVIL");
setLocationRelativeTo (null);
}
BOTON CALCULAR
String costo;
String ncuotas;
double monto,mostrardscto;
double increment=0,igv =
0,dscto=0,desct=0,descuento=0,montoToyota,montoNissan,montoHyunday;
float montototal=0,mostrarincremento,pagocuota;
ncuotas=txtNcuotas.getText();
costo=txtCostoBase.getText();
boolean verfiCosto, verifiPago,verifiMarca, verifiPuertas;
verifiMarca= rbToyota.isSelected() || rbNissan.isSelected() ||
rbHyunday.isSelected();
verifiPuertas= rb3.isSelected() || rb4.isSelected() || rb5.isSelected();
verifiPago= rbContado.isSelected()|| rbCredito.isSelected();

if (costo.equals("")){
JOptionPane.showMessageDialog(null,"PORFAVOR, INGRESE EL
PRECIO DEL AUTOMOVIL");}
if (!verifiMarca){
JOptionPane.showMessageDialog(null,"PORFAVOR, ELIGA LA MARCA DEL
AUTOMOVIL");
} if (!verifiPago){
JOptionPane.showMessageDialog(null,"PORFAVOR, SELECCIONE UN TIPO
DE PAGO");
} if (!verifiPuertas){
JOptionPane.showMessageDialog(null,"PORFAVOR, SELECCIONE LA
CANTIDAD DE PUERTAS");
}
else{
if (rbCredito.isSelected()){
if (ncuotas.equals("")){
JOptionPane.showMessageDialog(null,"PORFAVOR, INGRESE LA CANTIDAD
DE CUOTAS");
} else {
int numcuotas=Integer.parseInt(txtNcuotas.getText());
double costoAuto=Double.parseDouble(txtCostoBase.getText());
if(numcuotas>60){
JOptionPane.showMessageDialog(null,"EL NUMERO DE CUOTAS NO DEBE
SUPERAR A 60");}
if (numcuotas<=24){
dscto=costoAuto*0.95;
if (rbToyota.isSelected()){
montoToyota=dscto*1.18;
if (rb3.isSelected()){
increment=montoToyota;}
if(rb4.isSelected()){
increment=montoToyota*1.05;}
if (rb5.isSelected()){
montoToyota=dscto*1.12;}
}
if (rbHyunday.isSelected()){
montoHyunday=dscto*1.12;
if (rb3.isSelected()){
increment=montoHyunday;}
if (rb4.isSelected()){
increment=montoHyunday*1.05;}
if (rb5.isSelected()){
increment=montoHyunday*1.08;}
}
if (rbNissan.isSelected()){
montoNissan=dscto*1.15;
if (rb3.isSelected()){
increment=montoNissan;}
if (rb4.isSelected()){
increment=montoNissan*1.05; }
if (rb5.isSelected()){
increment=montoNissan*1.08;}
}
mostrarincremento=(float)(increment-dscto);
montototal=(float) ((costoAuto*0.95)+mostrarincremento);
pagocuota=(float)((montototal+mostrarincremento)/numcuotas);
igv=costoAuto*0.19;
mostrardscto=costoAuto*0.05;
txtPagocuota.setText(pagocuota+"");
txtIGV.setText(igv+"");
txtIncremento.setText(mostrarincremento+"");
txtPrecio.setText(montototal+"");
}
if (numcuotas>24 && numcuotas<=42){
dscto=costoAuto*0.93;
if (rbToyota.isSelected()){
montoToyota=dscto*1.18;
if(rb4.isSelected()){
increment=montoToyota*1.05;}
if (rb5.isSelected()){
increment=montoToyota*1.08;}
}
if (rbHyunday.isSelected()){
montoHyunday=dscto*1.12;
if(rb3.isSelected()){
increment=montoHyunday;}
if (rb4.isSelected()){
increment=montoHyunday*1.05;}
if (rb5.isSelected()){
increment=montoHyunday*1.08;}
}
if (rbNissan.isSelected()){
montoNissan=dscto*1.15;
if(rb3.isSelected()){
increment=montoNissan;}
if (rb4.isSelected()){
increment=montoNissan*1.05; }
if (rb5.isSelected()){
increment=montoNissan*1.08;}
}
mostrarincremento=(float)(increment-dscto);
montototal=(float)((costoAuto*0.95)+mostrarincremento);
pagocuota=(float)((montototal+mostrarincremento)/numcuotas);
igv=costoAuto*0.19;
mostrardscto=costoAuto*0.07;
txtPagocuota.setText(pagocuota+"");
txtIGV.setText(igv+"");
txtIncremento.setText(mostrarincremento+"");
txtPrecio.setText(montototal+"");
}
if (numcuotas>42 && numcuotas<=60){
dscto=costoAuto*0.09;
if (rbToyota.isSelected()){
montoToyota=dscto*1.18;
if(rb3.isSelected()){
increment=montoToyota;}
if(rb4.isSelected()){
increment=montoToyota*1.05;}
if (rb5.isSelected()){
increment=montoToyota*1.08;}
}
if (rbHyunday.isSelected()){
montoHyunday=dscto*1.12;
if(rb3.isSelected()){
increment=montoHyunday;}
if (rb4.isSelected()){
increment=montoHyunday*1.05;}
if (rb5.isSelected()){
increment=montoHyunday*1.08;}
}
if (rbNissan.isSelected()){
montoNissan=dscto*1.15;
if (rb3.isSelected()){
increment=montoNissan;}
if (rb4.isSelected()){
increment=montoNissan*1.05; }
if (rb5.isSelected()){
increment=montoNissan*1.08;}
}
mostrarincremento=(float)(increment-dscto);
montototal=(float)((costoAuto*0.95)+mostrarincremento);
pagocuota=(float)((montototal+mostrarincremento)/numcuotas);
igv=costoAuto*0.19;
mostrardscto=costoAuto*0.09;
txtPagocuota.setText(pagocuota+"");
txtIGV.setText(igv+"");
txtIncremento.setText(mostrarincremento+"");txtPrecio.setText(montototal+"");
}
}
}

BOTON LIMPIAR:
private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {
txtCostoBase.setText("");
rbToyota.setSelected(false);
rbNissan.setSelected(false);
rbHyunday.setSelected(false);
rb3.setSelected(true);
rb4.setSelected(false);
rb5.setSelected(false);
rbContado.setSelected(false);
rbCredito.setSelected(true);
txtNcuotas.setText("");
txtDescuento.setText("");
txtIGV.setText("");
txtPagocuota.setText("");
txtIncremento.setText("");
txtPrecio.setText("");
txtCostoBase.requestFocus();
BOTON CERRAR:
private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {
dispose();
}
EJERCICIO N°02
CAPTURAS DE LA EJECUCIÓN:
INTERPRETACIÓN:
Empezamos validando los objetos de control, para poder ejecutar botón calcular sin
errores ni vacíos, esto lo hacemos atreves de un método privado usando los métodos de
selección y campo de texto para su evaluación.
En la línea 209 procedemos a crear tres variables para almacenar los resultados de
bonificación, descuento y sueldo neto. De la misma forma procesamos la información
haciéndola fluir con unas secuencias de sentencias selectivas para poder interpretar los
variables de los JComboBox que almacenan el grado. Usamos el método
getSelectedIndex y evaluar la condición de cada persona y asimismo poder calcular con
referencia orientada a las alternativas, para poder aplicarle los valores de bonificación al
sueldo base.
Después más abajo en la línea 229 procedemos a condicionar si los JCheckBox están
seleccionadas, para saber si esta persona tiene hijos o no para aplicar un descuento o nada,
también hacemos lo mismo con el JCheckBox para los hijos.
Posteriormente enviamos las variables ya convertidos a String a mostrarse atreves del
Método SetTex en la pantalla grafica con los valores ya obtenidos en el proceso.
Botón limpiar:
En este objeto Simplemente Creamos un método Privado para poder establecer en él,
valores de inicialización o limpieza, esto lo podemos hacer usando métodos como:
getSelectedIndex, SetSelected o SetTex.
Instanciamos el método y listo.
Botón cerrar:
Hacemos uso del Método Dispose(), para poder cerrar el programa al clickear este botón.
CODIGO DE PROGRAMACIÓN:
package semana08;
import javax.swing.JOptionPane;
public class Formulario02 extends javax.swing.JFrame {
public Formulario02() {
initComponents();
setLocationRelativeTo(null);
}
private boolean validarAgregar() {
boolean validar;
validar = txtSB.getText().isEmpty() || cboGrado.getSelectedIndex() == 0 ||
cboCondicion.getSelectedIndex() == 0;
return validar;
}
private void limpiar() {
txtSB.setText("");
txtSB.requestFocus();
cboGrado.setSelectedIndex(0);
cboCondicion.setSelectedIndex(0);
chkSV.setSelected(false);
chkHijos.setSelected(false);
txtBonificacion.setText("");
txtDescuento.setText("");
txtSN.setText("");
}
BOTON CALCULAR:
private void btnCalcularActionPerformed(java.awt.event.ActionEvent evt) {
if (!validarAgregar()) {
double boni = 0.0, sb, dcto, sn, sbruto;
sb = Double.parseDouble(txtSB.getText());
if (cboGrado.getSelectedIndex() == 1) {
boni = sb * 0.05;
}
if (cboGrado.getSelectedIndex() == 2) {
boni = sb * 0.12;
}
if (cboGrado.getSelectedIndex() == 3) {
boni = sb * 0.18;
}
if (cboCondicion.getSelectedIndex() == 1) {
boni = boni + sb * 0.04;
}
if (cboCondicion.getSelectedIndex() == 2) {
boni = boni + sb * 0.1;
}
if (cboCondicion.getSelectedIndex() == 3) {
boni = boni + sb * 0.05;
}
if (chkSV.isSelected()) {
boni = boni + sb * 0.03;
}
if (chkHijos.isSelected()) {
boni = boni + sb * 0.06;
}
sbruto = sb + boni;
dcto = sbruto * 0.11;
sn = sbruto - dcto;
txtBonificacion.setText(String.valueOf(boni));
txtDescuento.setText(String.valueOf(dcto));
txtSN.setText(String.valueOf(sn));
} else {
JOptionPane.showMessageDialog(null, "Faltan datos para calcular");
}
}
BOTON BORRAR:
private void btnBorrarActionPerformed (java.awt.event.ActionEvent evt) {
limpiar();
}
BOTON CERRAR:
private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {
dispose();
}

Vous aimerez peut-être aussi