Sanchez Lesson 1
Sanchez Lesson 1
WRITTEN ACT#1
- A Windows is a graphical user interface (GUI) element that represents an open application or
document on a computer. It typically includes a title bar, menu bar, and a toolbar. A Window can
be resized, minimized, and closed.
A Dialog Box is a type of window that is used to display information or to receive input from the
user. Dialog boxes are typically used to prompt the user for information or to display important
messages. They often have buttons for the user to interact with, such as "OK" or "Cancel."
package sanchez;
public class Sanchez { package sanchez;
public static void main(String[] import javax.swing.*;
args) { public class Sanchez {
System.out.println(" Welcome to public static void main(String[] args)
Java Program"); {
} JOptionPane.showMessageDialog(null
} ,"Welcome to Earth");
}
}
SAMPLE 2: INPUT NAME
DOS-BASED WINDOWS-BASED
OUTPUT: OUTPUT:
package sanchez;
import java.util.Scanner;
public class Sanchez {
public static void main(String[]
args)throws Exception {
Scanner x = new Scanner (System.in);
String name;
System.out.print("Enter your name: ");
name=x.nextLine();
System.out.println("Your name is "+ package sanchez;
name); import javax.swing.*;
public class Sanchez {
} public static void main(String[]
args)throws Exception {
} String putName=
JOptionPane.showInputDialog(n
ull,"Enter your name: ");
JOptionPane.showMessageDialo
g(null,"Your name is" +
putName);
}
}
SAMPLE 3: ADDING TWO NUMBER
DOS-BASED WINDOWS-BASED
OUTPUT: OUTPUT:
package sanchez;
import java.util.Scanner;
public class Sanchez {
public static void main(String[]
args)throws Exception {
Scanner x = new Scanner
(System.in);
int n1,n2,sum;
String num1,num2;
System.out.print("Enter a number:
"); package sanchez;
n1= x.nextInt(); import javax.swing.*;
System.out.print("Enter you public class Sanchez {
public static void main(String[]
Second number: " );
args)throws Exception {
n2= x.nextInt();
int n1,n2,sum;
sum = n1+n2; String num1,num2;
System.out.println("The sum num1 =
is "+ sum); JOptionPane.showInputDialog(null,
"Enter your first number: ");
} n1= Integer.parseInt(num1);
num2=
} JOptionPane.showInputDialog(null,
"Enter your second number: ");
n2= Integer.parseInt(num2);
sum = n1+n2;
JOptionPane.showMessageDialog(n
ull,"The sum is "+ sum);
}
ASSIGNMENT:
Example 1:
package sanchez;
import javax.swing.*;
}
Example 2:
package sanchez;
import javax.swing.*;
Example 3:
package sanchez;
import javax.swing.*;
public class Sanchez {
JOptionPane.showMessageDialog(null,"RESET PASSCODE?",
"Windows Caption",JOptionPane.QUESTION_MESSAGE);