Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: calculation in GUI interface

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question calculation in GUI interface

    Hello there,

    I'm trying to create a GUI interface in Netbeans that calculates a phone bill.

    I created a GUI interface that input:
    - Account Name.
    - Account Number.
    - Number of Minutes the phone was used. (with a textarea so the user input the minutes)
    - 2 JRadioButtoms so the user can chose the regular or premium service.
    - Amount Due (+10% taxes) (also with a textarea)
    - Clear/Enter/Result/Done Buttoms

    And I need to output:
    - Account Name.
    - Account Number.
    - Number of Minutes.
    - Taxes
    - Total Amount Due.

    I have a couple of math formulas I have to add them to output the above however I'm new to java so I don't know which code to use.

    The math formulas are:
    -Regular charges = 20 + ( No. Minutes - 50 ) * 0.20
    -Premium charges = 50 + ( No. Minutes - 75 ) * 0.50
    -Taxes = ( Regular charges + Premium charges ) * 0.10
    -Amount Due = Regular charges + Premium charges + Taxes


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: calculation in GUI interface

    What have you tried?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: calculation in GUI interface

    I tried different methods but they don't work. i thing there was something wrong with the code. also, i named each variable a name and i wrote -- System.out.print((a+(min. + c) * b)); -- something like that.
    but i don't know which code to use i'm kinda slow with java loooool

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: calculation in GUI interface

    It's hard to make suggests about your code without seeing it.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: calculation in GUI interface

    private void ENTERActionPerformed(java.awt.event.ActionEvent evt) {
    //- Regular charges = 20+ ( R min – 50)*0.20
    //- Premium charges = 50+ ( P min – 75) * 0.50
    //- Sales tax=(R charges + P charges)*0.10
    //- Amount due= Regular charges + Premium charges + Sales tax
    double a = 20;
    double b = 50;
    double c = 0.20;
    double d = 50;
    double e = 75;
    double f = 0.50;
    double rmin = Double.parseDouble(NMTEXT.getText());
    double pmin = Double.parseDouble(NMTEXT.getText());
    System.out.print((a+(rmin-50)*c));

    }

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: calculation in GUI interface

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    Ok, what are your problems?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Apr 2014
    Location
    Nigeria
    Posts
    5
    My Mood
    Relaxed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: calculation in GUI interface

    I think you should first of all understand the problem you are trying to solve before solving it.You said you wanted to develope a programm to calculate phone bill ,from your code i cant connect the problem with the code you have there.Try to be more explicit.

Similar Threads

  1. Replies: 1
    Last Post: May 15th, 2013, 08:47 AM
  2. BMI calculation
    By dantheman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 28th, 2012, 09:57 PM
  3. Having problems with GUI Interface
    By Harrald in forum What's Wrong With My Code?
    Replies: 7
    Last Post: August 19th, 2012, 09:57 PM
  4. [SOLVED] Is it possible for a mouse listener to exist without a GUI interface?
    By techwiz24 in forum Java Theory & Questions
    Replies: 3
    Last Post: August 3rd, 2011, 02:32 PM
  5. I need calculation
    By Swiss518 in forum Loops & Control Statements
    Replies: 7
    Last Post: January 27th, 2011, 01:26 PM

Tags for this Thread