Вы находитесь на странице: 1из 3

UNIVERSIDAD VALLE DEL GRIJALVA

CAMPUS CAMPECHE
Materia: SEGURIDAD EN LA INFORMACIN Grupo: 8 AME (1504) 8 CUATRIMESTRE
EXAMEN PRIMER PARCIAL
Catedrtico: MARCELO GPE. SEGOVIA MAYO Fecha: 22/03/2017

Alumno(a): ___________________________________ Calificacin: ____________


Instrucciones: 1) Resolver su evaluacin con tinta (negra o azul). 2) No utilizar corrector. 3) En las preguntas de
opcin mltiple (si las hay) solo debe seleccionar una respuesta, no remarcar, ni seleccionar dos opciones. 4) En las
preguntas abiertas (si las hay) debe escribir claro, con una redaccin coherente y cuidando la ortografa. 5)
Entregar su pase de examen (Verificar que sea de la Asignatura), no debe estar roto, ni remarcado su nombre o
materia.
I. ELABORAR PROGRAMA EN JAVA QUE COMPRUEBE SI EL EMAIL ES CORRECTO
package compruebamail;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class comprouebamil extends JFrame {

private JPanel contentPane;


private JTextField correo;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
comprouebamil frame = new
comprouebamil();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
UNIVERSIDAD VALLE DEL GRIJALVA
CAMPUS CAMPECHE
* Create the frame.
*/
public comprouebamil() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabel lblIntroduceTuCorreo = new JLabel("Introduce tu


correo");
lblIntroduceTuCorreo.setBounds(28, 48, 154, 16);
contentPane.add(lblIntroduceTuCorreo);

correo = new JTextField();


correo.setBounds(28, 77, 276, 22);
contentPane.add(correo);
correo.setColumns(10);

JButton btnComprobar = new JButton("comprobar");


btnComprobar.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

boolean arroba = false;


String mail = correo.getText();
int longitud = mail.length();

for (int i = 0; i < longitud; i++) {


if (mail.charAt(i)=='@'){
arroba = true;

}
}
if (arroba == true) {
JOptionPane.showMessageDialog(null,
"correo correcto");
}
else {
JOptionPane.showMessageDialog(null,
"correo incorrecto");
}
}
});
btnComprobar.setBounds(155, 112, 97, 25);
contentPane.add(btnComprobar);
}
UNIVERSIDAD VALLE DEL GRIJALVA
CAMPUS CAMPECHE
}

Вам также может понравиться