Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Sumar Los Elementos de La Cola
Sumar Los Elementos de La Cola
private void
SumarLosElementosDeLaColaActionPerformed(java.awt.event.ActionEvent evt) {
//SUMAR LOS ELEMENTOS DE LA COLA
int elem,suma =0;
while(!q.isEmpty()){
elem=Integer.parseInt(q.poll().toString());
suma=suma+elem;
aux.add(elem);
}
JOptionPane.showMessageDialog(rootPane,
"LA SUMA DE LOS ELEMENTOS DE LA COLA ES: "+suma);
q=aux;
}
ELIMINAR LOS ELEMENTOS IMPARES DE LA COLA
private void
EliminarLosElementosImparesActionPerformed(java.awt.event.ActionEvent evt) {
// ELIMINAR LOS ELEMENTOS IMPARES
int elem;
while(!q.isEmpty()){
elem=Integer.parseInt(q.poll().toString());
if(elem%2==0){
aux.add(elem);
}
q=aux;
Mostrar();