import javax.swing.*;
public class comoanyname {
public static void main(String args[]) {
// declare and initialize variables
String openingMsg, nameInputMsg, customerName, nameOutputMsg,
returnInputMsg, customerReturn, returnOutputMsg,
greetingOutputMsg, outputMsg;
String openingMsg1, openingMsg2, openingMsg3, openingMsg4, openingMsg5,
openingMsg6, openingMsg7;
String loginMsg,userid, pwMsg, password, returnFlag,
invalidEntry;
Boolean returnYes, returnNo, returnInvalid, returnName, validCustomer,
reurnFlag;
// display opening message
openingMsg1 = "*** Welcome to companyname Online Ordering System ***";
openingMsg2 = "You are now able to order items through our online ordering system";
openingMsg3 = "take-out order system. \n\n";
openingMsg4 = "The paint colors you can order are: ";
openingMsg5 = "Red, Blue, White, Royal Blue, green";
openingMsg6 = "The paint sizes that you can order are: ";
openingMsg7 = "Small, Medium, and Large. \n\n";
JOptionPane.showMessageDialog(null, openingMsg);
//determing if they are a new or returning customer
returnInputMsg = "Are you a returing customer (Enter y or n)?";
customerReturn = JOptionPane.showInputDialog( returnInputMsg);
returnYes = customerReturn.equalsIgnoreCase("y");
returnNo = customerReturn.equalsIgnoreCase("n");
//initialize return flag
if(returnYes)
returnFlag = "1";
if(returnNO)
returnFlag = "2";
//determing if new customer or returning customer
switch(returnFlag)
{
case 1:
loginMsg = "Please enter your current username: ";
userid = JOptionPane.showInputDialog(null, loginMsg);
pwMsg = "Please enter your New Password: ";
password = JOptionPane.showInputDialog(null, pwMsg);
break;
case 2:
loginMsg = "Please enter your New username: ";
userid = JOptionPane.showInputDialog(null, loginMsg);
pwMsg = "Please enter your New passwprd: ";
password = JOptionPane.showInputDialog(null, pwMsg);
break;
default:
JOptionPane.showMessageDialog(null, invalidEntry);
loginMsg = "Please enter your New username: ";
userid = JOptionPane.showInputDialog(null, loginMsg);
pwMsg = "Please enter your New password: ";
password = JOptionPane.showInputDialog(null, pwMsg);
}//end switch
//get required customer name using dialog boxes
nameInputMsg = "Please enter your name: ";
customerName = JOptionPane.showInputDialog( nameInputMsg );
//repeat until a name is entered or exit after 3 tries
for (int i=1; i<=3; i++)
{
validCustomer = customerName.isEmpty();
if (validCustomer)
{
JOptionPane.showMessageDialog(null, invalidEntry);
if (==3)
System.exit(0);
else
{
nameInputMsg = "Please enter your name: ";
customerName = JOptionPane.showInputDialog( nameInputMsg);
}
}
else
break;
}
// build output strings
nameOutputMsg = "Welcome " + customerName + ".\n";
returnOutputMsg = "Your return customer status is " + customerReturn + ".\n";
greetingOutputMsg = "Thank you for visiting companyname!" + ".\n";
// create outputstring
outputMsg = nameOutputMsg + returnOutputMsg + greetingOutputMsg;
// display output message
outputMsg = "*** Come back for future orders! ***";
JOptionPane.showMessageDialog( null, outputMsg );
} // end main
} // end class