Results 1 to 4 of 4
  1. #1
    Sinman is offline Member
    Join Date
    Jul 2014
    Posts
    2
    Rep Power
    0

    Unhappy Stuck at one program. Needs Help

    You are running a Computer shop where you are selling some computer parts.
    Price for USB is $20.0
    Price for Key Board is $12.0
    Price for Mouse is $10.0.
    The three text boxes in this program initially disabled. To enter value in the each text box you would check mark the each check box for an item a customer was purchasing.
    This would enable that item's text field so you can enter the quantity. You would do this for each type of item the customer was purchasing.
    When you entered the quantities of each item, you would click the Total button. This would show output in the text area.
    You can enter a discount in the Discount field if you wish. If a discount was entered, it would also appear in the output
    The Reset button puts the form back to its original state (quantity text fields disabled and cleared, check boxes unchecked, text area and discount field cleared).
    The Exit button prompts you - are you sure you want to exit? If the user confirms that they wish to exit, the program terminates.
    I wrote this code for exit button (
    int ok;
    ok = JOptionPane.showConfirmDialog(null, "Are You Sure, You Want To Exit?", "EXIT", JOptionPane.YES_NO_OPTION);
    if (ok == JOptionPane.YES_OPTION)
    {
    System.exit(0);
    })
    This for Reset (
    CB1.setSelected(false);
    CB2.setSelected(false);
    CB3.setSelected(false);
    TF1.setEnabled(false);
    TF2.setEnabled(false);
    TF3.setEnabled(false);
    TF1.setText("");
    TF2.setText("");
    TF3.setText("");
    TF4.setText("");
    TA1.setText("");)
    But do not know how to calculate the Total. Please help me out
    Stuck at one program. Needs Help-hello.png

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: Stuck at one program. Needs Help

    What do you mean, "don't know how to calculate the total". You don't know how to do basic additions, subtractions and multiplications?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    7

    Default Re: Stuck at one program. Needs Help

    It sounds like asking basic mathematical formulas. However, I would just like to point out the way.

    you can use getText() method to retrive the value which user enters in text box.

    Then, Parse the string to int and the calculate total amout by muliplying items count with base price

    Afterwards, subtract total amount with discount price. you may get net amount.

    As usual, set the netamount using setText() method.

    P.S I assume you are a newbie to Java
    Mak
    (Living @ Virtual World)

  4. #4
    Sinman is offline Member
    Join Date
    Jul 2014
    Posts
    2
    Rep Power
    0

    Default Re: Stuck at one program. Needs Help

    Thank you for your replies. I appreciate it. @Makpandian I solved this program and it is running without errors. @Gimbal2 I know the maths & I was asking how to apply that and which method to use. Thank you Guys again.

Similar Threads

  1. Getting stuck developing CAD program
    By Digital Larry in forum AWT / Swing
    Replies: 1
    Last Post: 03-23-2013, 07:03 AM
  2. Stuck on a banking program
    By Ortlep in forum New To Java
    Replies: 2
    Last Post: 12-14-2011, 08:37 PM
  3. Stuck - simple program
    By dirtycash in forum New To Java
    Replies: 4
    Last Post: 11-24-2008, 08:44 PM
  4. Really Stuck on how to Start this program
    By random0munky in forum New To Java
    Replies: 4
    Last Post: 10-29-2008, 09:57 AM
  5. FireSimulation Program, got stuck with a bug...
    By riz618 in forum New To Java
    Replies: 5
    Last Post: 01-28-2008, 04:48 PM

Tags for this Thread

Posting Permissions

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