Documentos de Académico
Documentos de Profesional
Documentos de Cultura
int codigo;
String productos;
int cantidad;
double precioUnitario;
public lista_compras(){}
import java.util.ArrayList;
import javax.swing.JOptionPane;
public frame() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jtxtProducto.setBorder(javax.swing.BorderFactory.createTitledBorder("Descripcion del
producto"));
jtxtCantidad.setBorder(javax.swing.BorderFactory.createTitledBorder("Cantidad
del producto"));
jtxtPrecioUntiario.setBorder(javax.swing.BorderFactory.createTitledBorder("Precio
unitario"));
jtxtArea.setColumns(20);
jtxtArea.setRows(5);
jScrollPane1.setViewportView(jtxtArea);
jLabel2.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/imagenes/print.png"))); // NOI18N
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(39, 39, 39)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING, false)
.addComponent(jScrollPane1)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jtxtProducto,
javax.swing.GroupLayout.PREFERRED_SIZE, 170,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jtxtCantidad,
javax.swing.GroupLayout.PREFERRED_SIZE, 170,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jtxtPrecioUntiario,
javax.swing.GroupLayout.PREFERRED_SIZE, 170,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jbtnCalcularTotal,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jbtnRegistrar, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 41,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(87, 87, 87)))
.addContainerGap(49, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel1))
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 62,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jtxtProducto, javax.swing.GroupLayout.PREFERRED_SIZE,
60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jtxtCantidad, javax.swing.GroupLayout.PREFERRED_SIZE,
60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jtxtPrecioUntiario,
javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
210, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jbtnRegistrar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnCalcularTotal)
.addContainerGap(44, Short.MAX_VALUE))
);
if (jtxtProducto.getText().isEmpty() || jtxtCantidad.getText().isEmpty() ||
jtxtPrecioUntiario.getText().isEmpty()) {
JOptionPane.showMessageDialog(null, "Complete todos los campos");
} else {
cod++;
String producto = jtxtProducto.getText();
int cantidad = Integer.parseInt(jtxtCantidad.getText());
double precioU = Double.parseDouble(jtxtPrecioUntiario.getText());
lista_compras lista = new lista_compras(cod, producto, cantidad, precioU);
lis.add(lista);
JOptionPane.showMessageDialog(null, "Lista de productos agregados
correctamente");
}
if (i==lista.size()) {
return 0;
} else {
return lista.get(i).Totalproductos() + calcularTotalRecursivo(i+1, lista);
}
EJERCICIO 2
if (n == 0) {
return 1;
} else {
return n * factorialRecursivo(n - 1);
}
}
EJERCICIO 3
public class alumnos {
int dni;
String nombre;
String apellido;
int edad;
String genero;
String curso;
String fechadeingreso;
public alumnos(){}
public alumnos(int dni, String nombre, String apellido, int edad, String genero, String
curso, String fechadeingreso) {
this.dni = dni;
this.nombre = nombre;
this.apellido = apellido;
this.edad = edad;
this.genero = genero;
this.curso = curso;
this.fechadeingreso = fechadeingreso;
}
int contahombres = 0;
int contamujeres = 0;
int contaMate = 0;
int ContaEstructura = 0;
int contaMayores = 0;
int contaMenores = 0;
switch (al.getGenero()) {
}
return """
--CONTEO DE ALUMNOS--
Numero de Alumnos hombres: """ + contahombres
+ "\nNumero de Alumnas mujeres: " + contamujeres
+ "\nNumero de Alumnos en Matematica: " + contaMate
+ "\nNumero de Alumnos en Estructura de datos: " + ContaEstructura
+ "\nNumero de trabajadores mayores de edad: " + contaMayores
+ "\nNumero de trabajadores menores de edad: " + contaMenores;
}
if (izq>=der) {
return numeros;
}
while(izq!=der){
while(numeros[der].getEdad()>=numeros[pivote].getEdad()&&izq<der){
der--;
}
while (numeros[izq].getEdad()< numeros[pivote].getEdad()&& izq < der){
izq++;
}
if (der!=izq) {
aux = numeros[der];
numeros[der]=numeros[izq];
numeros[izq]=aux;
}
}
if (izq==der) {
quicksort2(numeros, i ,izq -1);
quicksort2(numeros, izq+1, d);
}
}else{
return numeros;
}
return numeros;
}
EJERCICIO 4