Write a Java Program that prompts the user to enter his/her first name and last name, then displays a message to welcome the user into the class CIS 226. If the user hits Cancel on either first or last name, show the error message:
import javax.swing.JOptionPane;
public class Assign2
{
// main method begins execution of Java application
public static void main( String[] args )
{
String firstname = JOptionPane.showInputDialog("Please enter your first name");
String lastname = JOptionPane.showInputDialog("Please enter your last name");
JOptionPane.showMessageDialog(null, "Hello, " + firstname + " " + lastname + ", " + "Welcome to CIS 226");
}
}