Wednesday, April 20, 2011

Waxing Business Revenue

SCA OOP class AIEP

Exercise to request information on the screen. Working with IF, ELSE, WHILE

package

windows import
javax.swing.JOptionPane;

LasPeticiones


public class String {

name;

public

LasPeticiones () {
pideNombre ();
/ / muestraSaludo ();
& # 160; mostrarNombreWhile ();}

public void pideNombre () {
JOptionPane.showInputDialog name = (null, "Enter here");}

muestraSaludo public void () {
if (name == null) {
& # 160; JOptionPane.showMessageDialog (null, "Cancel pressed");
& # 160; } Else if (nombre.equals ("")){
& # 160; JOptionPane.showMessageDialog (null, "Enter your name");
& # 160;} else {
; JOptionPane.showMessageDialog (null, "Name: "+ Name);

}}

mostrarNombreWhile public void () {
while ((name = = null) here ");}

JOptionPane.showMessageDialog (null," , Name: "+ name);

}}


Exercise

Error capturing

capturarerror package;

import javax. swing.JOptionPane;
public class

generarError {String message;

generarError public () {

ErrorNumero ();

& # 160;} public void

ErrorNumero () {

& # 160; message = JOptionPane.showInputDialog (null, "Enter here a whole");
try {
int value = Integer.parseInt (message);
} catch (NumberFormatException ex) {
, message = "You must enter a number" ;}

& # 160; JOptionPane.showMessageDialog (null, message);

}}


0 comments:

Post a Comment