0% found this document useful (0 votes)
55 views13 pages

Info1 ActivIntegradora Oblig 1

The document appears to be a student assignment to code a Java program that does the following: 1) Takes input from the user for the number of students (N) 2) Loops N times to take 3 test scores as input for each student 3) Calculates the average test score for each student 4) Calculates the overall average test score and highest average among all students The student has provided the starting code for a Java program with labels and text fields to take user input.

Uploaded by

sebastian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views13 pages

Info1 ActivIntegradora Oblig 1

The document appears to be a student assignment to code a Java program that does the following: 1) Takes input from the user for the number of students (N) 2) Loops N times to take 3 test scores as input for each student 3) Calculates the average test score for each student 4) Calculates the overall average test score and highest average among all students The student has provided the starting code for a Java program with labels and text fields to take user input.

Uploaded by

sebastian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

alumno

[Nombre de la compañía]
[Fecha]

INFORMATICA

FACULTAD CIENCIAS DE LA
ADMINISTRACION

Alumno: Bigot Sebastian

Profesor:
INFORMÁTICA 1
ACTIVIDAD INTEGRADORA OBLIGATORIA NRO. 1–

Realizar el programa en java para cada uno de los siguientes problemas

1) Cargar N (la cantidad de alumnos deberá ingresarse por teclado) Cargar


tres notas por alumno y mostrar el promedio de cada alumno. Al finalizar la
carga mostrar el promedio general y el mayor promedio. (usar estructura for)
entre todos los alumnos.

Codigo
/*
* 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.
*/
package informe;

/**
*
* @author Usuario
*/
public class NewJFrame extends javax.swing.JFrame {

/**
* Creates new form NewJFrame
*/
public NewJFrame() {
initComponents();
}

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

menuBar1 = new java.awt.MenuBar();


menu1 = new java.awt.Menu();
menu2 = new java.awt.Menu();
popupMenu1 = new java.awt.PopupMenu();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
label1 = new java.awt.Label();
label2 = new java.awt.Label();
label3 = new java.awt.Label();
label4 = new java.awt.Label();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
label5 = new java.awt.Label();
label6 = new java.awt.Label();
label7 = new java.awt.Label();
label8 = new java.awt.Label();
jButton3 = new javax.swing.JButton();

menu1.setLabel("File");
menuBar1.add(menu1);

menu2.setLabel("Edit");
menuBar1.add(menu2);

popupMenu1.setLabel("popupMenu1");

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N


jLabel1.setText("Carga de Alumnos");

jLabel2.setFont(new java.awt.Font("Times New Roman", 2, 18)); // NOI18N


jLabel2.setText("Ingrese el Nombre:");

jLabel3.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N


jLabel3.setText("Ingrese el Apellido");

label1.setText("Ingrese la notas:");

label2.setText("Fisica");

label3.setText("Matematica");

label4.setText("Informatica");

jTextField4.setToolTipText("");
jTextField4.setDropMode(javax.swing.DropMode.INSERT);

jTextField5.setToolTipText("");

jButton1.setText("Cargar");
jButton1.setActionCommand("");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

label5.setText("Promedio Alumno");
label6.setText("Promedio General");

label7.setText("label7");

label8.setText("label8");

jButton3.setText("Salir");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton3)
.addGap(40, 40, 40))
.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(30, 30, 30)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jTextField2,
javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
.addComponent(jTextField1)))))
.addGroup(layout.createSequentialGroup()
.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label2,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label3,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label4,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jTextField6,
javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)
.addComponent(jTextField5)
.addComponent(jTextField4)))))
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(48, 48, 48)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label7, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label8, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(146, 146, 146)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE,
113, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(63, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jLabel1)
.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
31, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
28, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27)
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jTextField4)
.addComponent(label2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jTextField5)
.addComponent(label3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jTextField6)
.addComponent(label4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(66, 66, 66)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 42,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
50, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(label8, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addComponent(jButton3)
.addContainerGap())
);

pack();
}// </editor-fold>
int i =0;
String nombre, apellido, promA, promG;
int notaF, notaMat, notaInf;
float promedioAl, promedioGral, suma;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
for (i=0; i< notaF; i++)
//borramos cada ves que hacemos click

//cargamos los datos en los texfield


nombre= jTextField1.getText();
apellido = jTextField2.getText();
notaF = Integer.parseInt(jTextField4.getText());
notaMat = Integer.parseInt(jTextField5.getText());
notaInf = Integer.parseInt(jTextField6.getText());

promedioAl = (notaF+notaMat+notaInf)/3;//sacamos el promedio del alumno


promA = Float.toString(promedioAl);//comvertimos el dato a string
suma = promedioAl/i;
promedioGral= suma;
promG = Float.toString(promedioGral);

jTextField1.setText(null);
jTextField2.setText(null);
jTextField4.setText(null);
jTextField5.setText(null);
jTextField6.setText(null);
label7.setText(promA);
label8.setText(promG);

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Leve
l.SEVERE, null, ex);
}
//</editor-fold>

//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(() -> {
new NewJFrame().setVisible(true);
});
}

// Variables declaration - do not modify


private javax.swing.JButton jButton1;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private java.awt.Label label1;
private java.awt.Label label2;
private java.awt.Label label3;
private java.awt.Label label4;
private java.awt.Label label5;
private java.awt.Label label6;
private java.awt.Label label7;
private java.awt.Label label8;
private java.awt.Menu menu1;
private java.awt.Menu menu2;
private java.awt.MenuBar menuBar1;
private java.awt.PopupMenu popupMenu1;
// End of variables declaration
}

Use un formulario…

2) Ingresar por teclado las notas finales de N alumnos. Usando la estructura for
y la estructura switch-case, mostrar un mensaje de acuerdo a la nota ingresada:
1, 2 ó 3 -> Aplazado
4, 5 ó 6 -> Aprobado
7, 8, ó 9 -> Excelente
10 – Sobresaliente

Codigo

/*
* 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.
*/
package notasevalu;
import javax.swing.JOptionPane;
import javax.swing.Icon;
import javax.swing.ImageIcon;
/**
*
* @author Usuario
*/
public class Notasevalu {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Icon t,e,a,w,r;
t = new ImageIcon("src/Imagenes/disk1.png");
e = new ImageIcon("src/Imagenes/error.png");
a = new ImageIcon("src/Imagenes/go.png");
w = new ImageIcon("src/Imagenes/star.png");
r = new ImageIcon("src/Imagenes/bul.png");

JOptionPane.showMessageDialog(null,"BIenvenidos","Ingreso de Alumnos",
JOptionPane.INFORMATION_MESSAGE,t);
for (int i =0; i< i+1; i++){
String nombre = JOptionPane.showInputDialog("Ingrese el nombre del Alumno");
int nota = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la nota Final"));

switch(nota){
case 1:
JOptionPane.showMessageDialog(null, "APLAZADO", "Nota",
JOptionPane.INFORMATION_MESSAGE,e);
break;
case 2:
JOptionPane.showMessageDialog(null, "APLAZADO", "Nota",
JOptionPane.INFORMATION_MESSAGE,e);
break;
case 3:
JOptionPane.showMessageDialog(null, "APLAZADO", "Nota",
JOptionPane.INFORMATION_MESSAGE,e);
break;
case 4:
JOptionPane.showMessageDialog(null, "APROBADO", "Nota",
JOptionPane.INFORMATION_MESSAGE,a);
break;
case 5:
JOptionPane.showMessageDialog(null, "APROBADO","Nota",
JOptionPane.INFORMATION_MESSAGE,a);
break;
case 6:
JOptionPane.showMessageDialog(null, "APROBADO","Nota",
JOptionPane.INFORMATION_MESSAGE,a);
break;
case 7:
JOptionPane.showMessageDialog(null, "EXCELENTE","Nota",
JOptionPane.INFORMATION_MESSAGE,w);
break;
case 8:
JOptionPane.showMessageDialog(null, "EXCELENTE","Nota",
JOptionPane.INFORMATION_MESSAGE,w);
break;
case 9:
JOptionPane.showMessageDialog(null, "EXCELENTE","Nota",
JOptionPane.INFORMATION_MESSAGE,w);
break;
case 10:
JOptionPane.showMessageDialog(null, "SOBRESALIENTE","Nota",
JOptionPane.INFORMATION_MESSAGE,r);
break;

}
}

}
3-Ingresar de a uno una serie de números por teclado (usar estructura while).
La serie finaliza cuando aparece un número igual a 11. Sumar y mostrar la
cantidad de positivos y negativos y de pares e impares.

Codigo:
/*
* 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.
*/
package parimpar;

import javax.swing.JOptionPane;

/**
*
* @author Usuario
*/
import javax.swing.JOptionPane;
public class Parimpar {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int i,n=0, pares =0, impares=0, sumapar=0, sumaimpar =0;
int acum_nega=0, suma_nega=0;
// TODO code application logic here
JOptionPane.showMessageDialog(null,"Ingrese una serie de numero. Recuerde el n
11 termina el proceso");

while (n !=11){
n = Integer.parseInt( JOptionPane.showInputDialog("Ingrese los numeros"));
if (n %2 == 0){
pares = pares +1;

sumapar += n;
}else {

impares = impares +1;


sumaimpar += n ;
}
if (n<0){
acum_nega = +1;
suma_nega +=n;

}
}
JOptionPane.showMessageDialog(null,"La cantidad de numeros pares son: " + pares);
JOptionPane.showMessageDialog(null,"La cantidad de numeros impares son: "+
impares);
JOptionPane.showMessageDialog(null, "La suma de numeros pares es: " + sumapar);
JOptionPane.showMessageDialog(null, "La suma de numeros impares es: " +
sumaimpar);
JOptionPane.showMessageDialog(null,"La cantidad de numeros Negativos son
:"+acum_nega);
JOptionPane.showMessageDialog(null,"La suma de los negativos es :"+suma_nega);
}

4-Ingresar de a uno los salarios de los empleados de una empresa, la serie finaliza
cuando aparece un salario igual a 0 (usar estructura while). Los salarios se van a
aumentar de acuerdo a la siguiente tabla:

1 a $2000 incrementar el salario un 50% $2001


a $3000 incrementar el salario un 30% más de
$3000 incrementar el salario un 10%
Escribir un programa que solicite el salario actual del empleado, calcule y muestre el nuevo
salario.
Codigo
/*
* 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.
*/
package salarios;
import javax.swing.JOptionPane;
/**
*
* @author Usuario
*/
public class Salarios {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String op;
double a, por, sal1, por2, sal2, sal3, por3 = 0;
int c=0;
JOptionPane.showMessageDialog(null, "Bienvenidos a la empresa SOFTWEARE");
while (c<=1 ){
op = JOptionPane.showInputDialog(null, "Ingrese el nombre y apellido del operario");
a = Float.parseFloat(JOptionPane.showInputDialog(" Ingrese el salario de " + op));
if ( a>=1&& a<=2000){
por = (a*50)/100;
sal1 = por+a;
JOptionPane.showMessageDialog(null," el salario de : "+op +" es de "+a+" $.
Actualizado "+ sal1+ " Un incremento del 50% "+por +" $");
}
if (a>2000 && a <3000){
por2 = (a*30)/100;
sal2 = por2+a;
JOptionPane.showMessageDialog(null, " el salario de : "+op+ " es de. "+a+" $.
Actualizado "+sal2+" Un incremento del 30% "+por2+ " $ ");
}
if (a>=3000){
por3 = (a*10)/100;
sal3 = por3+a;
JOptionPane.showMessageDialog(null, " el salario de : "+op+ " es de. "+a+" $.
Actualizado "+sal3+ " Un incremento del 10% "+por3+" $ ");
}
c = JOptionPane.showConfirmDialog(null,"Desea cargar mas", "Cargar operarios",
JOptionPane.OK_CANCEL_OPTION);
}

NOTA: Los programas fuentes enviados no deben tener errores de compilación.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy