Results 1 to 2 of 2
  1. #1
    murr0508 is offline Member
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Default HELP!! Assignment due in one hour!

    I am new with java and continue to have problems. So far I have this:

    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) ***********************************************

    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).notequal("N") || pickupOption.substring(0,1).notequal("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).notequals("Y") || pickupOption.substring(0,1).notequals("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);
    }



    For some reason no matter what letter I type in for the pickupOption when the program is running my error message pops up that I must enter Y or N. Did I do something wrong???

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Please see comments in other post. Please do not double-post your questions.

    Also, what is this method?: notequal("N")
    String doesn't have such a method. If you want to test for not equals you must do something like:
    Java Code:
     if (!myString.equalsIgnoreCase("n"))
    Last edited by Fubarable; 02-26-2009 at 10:35 PM.

Similar Threads

  1. Help needed for a 40 mark homework due in 1 hour .. plz
    By q8ysurgeon in forum New To Java
    Replies: 5
    Last Post: 01-09-2009, 06:07 PM
  2. Help needed for a 40 mark homework due in 1 hour .. plz
    By q8ysurgeon in forum Advanced Java
    Replies: 3
    Last Post: 01-09-2009, 05:09 AM
  3. [SOLVED] Very Simple 2-3 hour project $50
    By arbit3r in forum Jobs Offered
    Replies: 3
    Last Post: 08-05-2008, 04:20 AM
  4. First GUI Assignment
    By ljk8950 in forum New To Java
    Replies: 1
    Last Post: 07-31-2008, 08:29 AM
  5. Calculating per hour statistics
    By vipergt89 in forum New To Java
    Replies: 2
    Last Post: 05-01-2008, 07:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •