Error message pops up no matter what?
public void deliveryCharge()
{
// VARIABLE DECLARATIONS/DEFINITIONS (IPO) ********************************************
// *** INPUT VARIABLES ***
DecimalFormat dollarDecimalPlaces = new DecimalFormat("$#,##0.00");//This is the dollar decimal format that gives the dollar amounts a dollar sign the correct decimal format.
String userName; //The user's name
String pickupOption; //Find out if the user is picking up
String packageWeightInfo;//String regarding to weight of package in pounds
double packageWeight = 0;//Weight of the package in pounds
double pickupCharge = 0;//Charge if user picks up package
char Y;
char X;
// *** PROCESSING VARIABLES ***
// (These may be constants intermediate or temporary storage variables.)
double cost = 0; //Cost per pound
// *** OUTPUT VARIABLES ***
double deliveryCharge;//This is the result of the program
// THE CODING STATEMENTS/ACTIONS (IIPO) ***********************************************
// INITIALIZATION
JOptionPane.showMessageDialog(null, "Welcome to the Dawg Delivery Service!");//Displays a welcoming message to the user
// INPUTS - COLLECT INPUT FROM THE USER OR ANOTHER SOURCE - AND VALIDATE THE INPUTS.
//Get the User's name:
userName = JOptionPane.showInputDialog("Please enter your full name.");//Asks the user to enter their name
if (userName.length() == 0)
{
JOptionPane.showMessageDialog(null, "ERROR! You cannot have a length of zero!"); //If nothing is entered in the userName input box, then this will pop up.
System.exit(0);
}
pickupOption = JOptionPane.showInputDialog("Is this package being picked up? Please enter Y or N:");//Asks user to enter if the package is being picked up. Only Y or N will be acceptable for answers.
if (pickupOption.substring(0,1).equals("Y") || pickupOption.substring(0,1).equals("y"))
{
pickupCharge = 2; //Gives correct pick up charge if item is picked up
}
if (pickupOption.substring(0,1).equals("N") || pickupOption.substring(0,1).equals("n"))
{
pickupCharge = 0; //Gives zero pick up charge if item is not picked up
}
if (pickupOption.substring(0,1) != ("N") || pickupOption.substring(0,1) != ("n"))
{
JOptionPane.showMessageDialog(null, "ERROR! You must enter Y or N!"); //If something other than Y or N is entered, then this will pop up.
System.exit(0);
}
if (pickupOption.substring(0,1) != ("Y") || pickupOption.substring(0,1) != ("y"))
{
JOptionPane.showMessageDialog(null, "ERROR! You must enter Y or N!"); //If something other than Y or N is entered, then this will pop up.
System.exit(0);
}
When my program is running, no matter what I type in for the pickupOption, it gives me my error message. WHY???