Help with limiting JOptionPane output to 2 decimal places

I don't seem to be able to figure out how to specify 2 decimal points in my output to a JOptionPane. I know how to do this in a standard program with no gui interface but I have been unsuccessful in my attempts with JOptionPane. I have included my code below and any assistance at all would be appreciated.
import javax.swing.JOptionPane;
public class Vehicleanalysis2
public static void main( String args[] )
String januaryRepairs =
     JOptionPane.showInputDialog( "Enter January's repair costs:" );
String februaryRepairs =
     JOptionPane.showInputDialog( "Enter February's repair costs:" );
String marchRepairs =
     JOptionPane.showInputDialog( "Enter March's repair costs:" );
String aprilRepairs =
     JOptionPane.showInputDialog( "Enter April's repair costs:" );
String mayRepairs =
     JOptionPane.showInputDialog( "Enter May's repair costs:" );
String juneRepairs =
     JOptionPane.showInputDialog( "Enter June's repair costs:" );
String julyRepairs =
     JOptionPane.showInputDialog( "Enter July's repair costs:" );
String augustRepairs =
     JOptionPane.showInputDialog( "Enter August's repair costs:" );
String septemberRepairs =
     JOptionPane.showInputDialog( "Enter September's repair costs:" );
String octoberRepairs =
     JOptionPane.showInputDialog( "Enter October's repair costs:" );
String novemberRepairs =
     JOptionPane.showInputDialog( "Enter November's repair costs:" );
String decemberRepairs =
     JOptionPane.showInputDialog( "Enter December's repair costs:" );
double january = Double.parseDouble(januaryRepairs );
double february = Double.parseDouble(februaryRepairs );
double march = Double.parseDouble(marchRepairs );
double april = Double.parseDouble(aprilRepairs );
double may = Double.parseDouble(mayRepairs );
double june = Double.parseDouble(juneRepairs );
double july = Double.parseDouble(julyRepairs );
double august = Double.parseDouble(augustRepairs );
double september = Double.parseDouble(septemberRepairs );
double october = Double.parseDouble(octoberRepairs );
double november = Double.parseDouble(novemberRepairs );
double december = Double.parseDouble(decemberRepairs );
double annualrepaircost = january + february + march + april + may + june + july + august + september + october + november + december;
double payment = annualrepaircost / 12;
if (annualrepaircost <= 3600 )
     JOptionPane.showMessageDialog(null, "          Keep your car.\n          Your monthly repair\n          costs only average\n           out to be: " + payment + "\n          Your annual repair costs\n          this year\n were: " + annualrepaircost, " Recommendation", JOptionPane.PLAIN_MESSAGE );
else
     JOptionPane.showMessageDialog(null, "          You should consider purchasing a new\n          car if you can get a payment\n          for less than: " + payment + "\n          Your annual repair costs\n          this year\n          were: " + annualrepaircost,
     " Recommendation: ", JOptionPane.PLAIN_MESSAGE );
}

Hi,
try the following:
double payment;
JOptionPane.showMessageDialog(null, String.format("Payment: %.2f ", payment));
/Mattias

Similar Messages

  • Help wanting to limit output to 2 decimal places :O

    im trying to make it so i only output over 2 decimal places.
    here is my code. can someone tell me what to add? thank you mucho
    package javaapplication2;
    import java.util.*;
    import cs1.Keyboard;
    public class Main {
    public static void main(String[] args) {
    double Hours_Worked,
    Hourly_Wage,
    Total_Money;
    final double COMMISSION = 3.59 * .1;
    int noSoldFish;
    String UserName;
    System.out.println("Please enter the employee's name: ");
    UserName = Keyboard.readString();
    System.out.println("Please enter hours worked by employee: ");
    Hours_Worked = Keyboard.readDouble();
    System.out.println("Enter employee's hourly wage: $");
    Hourly_Wage = Keyboard.readDouble();
    System.out.println("Enter the number of fish sold by employee:");
    noSoldFish = Keyboard.readInt();
    Total_Money = Hours_Worked * Hourly_Wage + noSoldFish * COMMISSION;
    System.out.println("\n===========================================" +
    "\n Employee's Information" +
    "\n===========================================" +
    "\n" + UserName + " worked " + Hours_Worked + " hours this week" +
    "\n" + UserName + " makes $" + Hourly_Wage + " per hour." +
    "\nThe total salary and commission for "
    + UserName + " is $" + Total_Money);
    System.exit(0);
    }

    read up on, or search the forum on NumberFormat and in particular the factory method NumberFormat.getCurrencyInstance(); This is what you need here.

  • How can I stabilize the DAQ output to four decimal places

    I have a daq 6009. I sent a optical signal. DAQ provides a output which varies in 3rd  decimal place. I done averaging all using a program which I'am attaching with this. So can you please help me in this regard 
    Attachments:
    data acquisition 2 (SubVI).vi ‏71 KB

    You need to find a DAQ with a lower Absolute Accuracy.
    Also, looking at the spec, you can get a better accuracy with a Differential measurement than you can with a RSE.  Apparently the RSE only works in the +-10V range.  By changing to a differential, you can get down to a +-1V range.  That will help your resolution a little bit.  Just wire the ground to the - terminals on the DAQ.
    Another issue could be noise in the system.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • ALV output is 2 decimal places, but prints as 3

    Hi,
    In my current ABAP program, the output is shown as 2 decimals, using the following domain:
    Data Type: QUAN
    No. Characters: 13
    Decimal Places: 2
    Output length: 17
    However, during unit testing, it was found that during printing, instead of printing it out as 2 decimals (ex. 12.00,) its printed out as 3 decimals (ex. 12.000.)
    The same thing can be noticed when using Print preview. It starts at the editable fields and continues onward to others.
    Why is this occurring and what can I do to fix this problem?
    Points will be rewarded and all help will be greatly appreciated.
    Thanks,
    John

    Hi
    Check once again the attributes of that Qty field in Dataelement and domain
    Because for all QUAN type fields it is always 3 DECIMAL places
    you are saying it is 2
    check it
    All the qty fields in SAP with data type QUAN uses/prints 3 decimals
    so check and  see
    like fields LFIMG.MENGE,FKIMG,KWMENG all fields with 3 decimals
    Reward points for useful Answers
    Regards
    Anji

  • Limiting AS distance to two decimal places

    I am just about there getting the Google Maps API talking to my SQL database. For my search results I have the SQL:
    SELECT *, ( 3959 * acos( cos( radians(" .$POST["latitude"] .") ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(" .$POST["longitude"] .") ) + sin( radians(" .$_POST["latitude"] .") ) * sin( radians( lat ) ) ) ) AS distance FROM VenuesGeocodes1 HAVING distance < 100 ORDER BY distance LIMIT 0 , 30;
    Which works great, but displays the distance with 15 decimal places which is complete overkill.
    How can I limit that to just two decimal places? I thought I just needed to change distance to distance (10,2), but it didn't like it.
    If anyone can let me know what it should be that would be much appreciated.
    Thanks.

    Thanks Rob - I also got it to work using ROUND in the query:
    SELECT *, ROUND( 3959 * acos....

  • PO with reference to contract nett price decimal place

    In a PO  with reference to contract when user ordered qty 0.046 and contract price = $100.00 with a 7 % tax rate, SAP takes (0.046 * 100) * 1.07 = 4.922
    However as PO is up to 2 decimal place, the nett price is cut off to 4.92
    Thus calculation of PO price (4.92 / 0.046) = 106.95652173u2026
    When rounded off to 2 decimal places, it becomes 106.96
    But in actual fact, it should 107.00
    Is there any way I can bypass this error?

    HI,
    The only solution I see is to create smaller unit of measure in a way that instead of ordering  0.046 you order 46, 0r 460.
    Best Regards,
    Arminda Jack

  • Help with formatting multiline output into comma delimited ordered output

    I have 2 tables:
    SQL> desc table_1;
    Name Null? Type
    ===================================
    ID NOT NULL NUMBER
    DATA1 NOT NULL VARCHAR2(440)
    DATA2 NOT NULL VARCHAR2(1024)
    SQL> desc table_2;
    Name Null? Type
    ===================================
    ID NOT NULL NUMBER
    ATTNAME NOT NULL VARCHAR2(255)
    ATTVAL                          VARCHAR2 (4000)
    DATA1 NOT NULL CHAR(1)
    DATA2                          VARCHAR2 (2000)
    DATA3                          VARCHAR2 (255)
    I need to get ATTVAL from where e.g. ATTNAME=att_name1 to ATTNAME=att_name6 from every entry (with its unique ID), and format the output into comma delimited format in e.g. this order:
    att_val1,att_val3,att_val6,att_val4,att_val5,att_val6
    So e.g. for entry with ID "9812" from the query below, the output I need would be:
    187,179,156,134,1436,1809
    What I've got so far is as follows:
    SQL> SELECT id,attname,attval FROM table_2 WHERE id in (SELECT id from table_1 WHERE data2='xxx')
    AND attname in ('att_name1','att_name3','att_name6','att_name4','att_name5','att_name6');
    ID               ATTNAME               ATTVAL
    ===============================
    1970 att_name1 123
    1970 att_name2 abc
    1970 att_name3 1234
    1970 att_name4 def
    1970 att_name5 1134
    1970 att_name6 ghj
    9812 att_name4 134
    9812 att_name5 1436
    9812 att_name3 156
    9812 att_name1 187
    9812 att_name2 179
    9812 att_name6 1809
    77 att_name1 1980
    77 att_name5 1867
    77 att_name3 174
    77 att_name4 1345
    77 att_name2 1345
    77 att_name6 1345
    but I don't know how to format the output comma limited in certain order. (or if this is the best way of getting the data out)
    Would someone have idea how this could be done?

    846954 wrote:
    Thanks Frank!
    I got much further now :).
    I've got Oracle 10g So I used the "SYS_CONNECT_BY_PATH" for my query.
    Now I get the output in the format I want, however, it comes out in the order that the attributes are (which is pretty random).The values you posted are in order: 'attval1' < 'attval2' < ...
    So I'm using this now(had to use "|" as separator because SYS_CONNECT_BY_PATH would not work with comma due to some of the attval having comma in them ):The values you posted don't contain and commas.
    You're hiding what the problem is. It would really help if you posted actual data. It always helps if you post CREATE TABLE and INSERT statements for a little sample data, and the results you want from that data.
    Assuming you really have something that has to be in a certain order, and that order is not based on anything in the values themselves, then DECODE might be a good way to do it. Storing the sort value in a table might be even better.
    It looks like you were using an Oracle 9 exanple. In Oracle 10, using SYS_CONNECT_BY_PATH is simpler:
    SELECT     id
    ,     LTRIM ( SYS_CONNECT_BY_PATH (attval, '|')
               , '|'
               )          AS attvals
    FROM     (
              SELECT     id
              ,     attval
              ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                  ORDER BY          DECODE (...)
                                )     AS curr
              WHERE     id     IN (
                             SELECT  id
                             FROM     table_1
                             WHERE     data2     = 'xxx'
              AND     attname     IN ('attname1','attname2','attname3','attname4','attname5','attname6')
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     curr     = 1
    CONNECT BY     curr     = PRIOR curr + 1
         AND     id     = PRIOR id
    ;You don't need two almost-identical ROW_NUMBERs; one will do just fine.

  • Help with limitations in a Canvas

    Hi!
    I'm having some troubles with the limitations of the Canvas, the thing is that i have an array with photos and i show them like the ipod does, the things is that i want to limit the size of the canvas or something, because the images slip outside the canvas, or HBOX or VBOX and overlap the other hbox that i have in the same canvas.
    Could you help me? Did you get the idea.
    The source is here. http://demo.quietlyscheming.com/displayShelf/index.html

    I seem to recall from the dim and distant past that simply putting "\n" in the text doesn't work. But what does work is setting the label with html rather than plain text - then you can add html line-break code. Or I could be talking out of my arse - can't remember. Try it anyway.

  • Need help with the text output here... kinda a newbie..

    Alright the problem I am having is with the output of this program. It does not appear to calculate the mortgage formula correctly and outputs some other data that does not make any sense. here is the code. Any help on this matter would be great!!
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class Calculator extends JFrame implements ActionListener {
    private JPanel panelAdder;
    private JLabel labela;
    private JLabel labelt;
    private JLabel labelr;
    private JTextField textFieldAmount;
    private JTextField textFieldTerm;
    private JTextField textFieldRate;
    private JTextField textFieldResult;
    private JButton buttonCalc;
    public Calculator() {
      initComponents();
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setVisible(true);
      pack();
      // Add Listeners
      buttonCalc.addActionListener(this);
    public void initComponents() {
    //Initialize Components
    panelAdder = new JPanel();
    labela = new JLabel("Amount");
    textFieldAmount = new JTextField();
    labelt = new JLabel("Term");
    textFieldTerm = new JTextField();
    labelr = new JLabel("Rate");
    textFieldRate = new JTextField();
    textFieldResult = new JTextField();
    buttonCalc = new JButton("Calculate");
    //Set Object Attributes
    textFieldResult.setEditable(false);
    textFieldResult.setColumns(8);
    textFieldAmount.setColumns(6);
    textFieldTerm.setColumns(2);
    textFieldRate.setColumns(2);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FlowLayout());
    //Lets add the components to the panel
    panelAdder.add(labela);
    panelAdder.add(textFieldAmount);
    panelAdder.add(labelt);
    panelAdder.add(textFieldTerm);
    panelAdder.add(labelr);
    panelAdder.add(textFieldRate);
    panelAdder.add(buttonCalc);
    panelAdder.add(textFieldResult);
    contentPane.add(panelAdder);
    public static void main(String[] args) {
      Calculator frame = new Calculator();
    private void setResultValue() {
       double amount = Double.parseDouble(textFieldAmount.getText());
       double term = Integer.parseInt(textFieldTerm.getText());
       double rate = Double.parseDouble(textFieldRate.getText()) / 100.;
       //double result = amount * ( rate * Math.pow ( ( 1 + rate ), term ) ) / ( Math.pow( ( 1 + rate ), term ) - 1 );
       double result = (amount*((rate/12)/(1-Math.pow((1+(rate/12)),-(term*12)))));
       textFieldResult.setText(Double.toString(result));
    public void actionPerformed(ActionEvent event) {
      System.out.println("Action Button");
      String command = event.getActionCommand();
      if (command == "Calculate") {
          setResultValue();
    }

    Alright the problem I am having is with the output of
    this program. It does not appear to calculate the
    mortgage formula correctly and outputs some other
    data that does not make any sense. here is the code.
    Any help on this matter would be great!!First of all, what is the mortgage formula?

  • I need some help with limiter on main outs, gurus please read :)

    Hello, I've just recently switched over from PT and I noticed almost immediately upon getting into logic that the main outs seem really loud when following my general mixing workflow that I'm use to using. In fact so much so that I can't really get a final product using ozone 4 like I was able to in PT. When I go to use the final stage of ozone 4 (the limiter) to maximize my volume without clipping, it pretty much just crushes my dynamics and overall mix into rubbish. What's going on here? What am I doing wrong? I'm not even limiting that much. Whereas before in PT I could limit it much more if I wanted to. Is there a setting somewhere in logic i'm missing? I know Pro tools and logic are different beasts so save the crappy comments, but there is a huge difference in main output behavior that just doesn't make sense to me and causes the same plug in (ozone 4) to act much differently.

    Well it's not a mental hang up, as I've tried turning down the master fader substantially and ozone 4 still reacts differently than in PT, it sounds better without the loudness maximizer going, fuller and more dynamic. Whereas in PT I was able to utilize the maximizer to bring the volume up to a point and still not smash the mix. I've noticed this with pretty much anything I use a limiter/maximizer on in Logic. I don't understand what's going on. Surely I have something set funky somewhere? It's like it's putting a brick wall limiter on the mix even when I set it to intelligent and tweak everything a bit my meters just straight line, no movement, as if I have my volumes cranked to the max. Very subtle settings in ozone
    we're talking -0.4 margin threshold -2.1 character set to very fast in intelligent II mode. This normally gives me a pretty decent amount of threshold adjustment to maximize volume. I'm stumped.

  • Help with an error output

    I have a FLVPlayback component for show videos from a menu. when the video get completed it returns to the menu, but when it returns, the menu items dont work again and i get this output, can somebody help me with this????
    TypeError: Error #1009: No se puede acceder a una propiedad o a un método de una referencia a un objeto nulo.
    at Popular2_fla::MainTimeline/frame1()
    at flash.display::MovieClip/gotoAndStop()
    at Popular2_fla::MainTimeline/completePlay()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.video::FLVPlayback/http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::httpDoStopAtEnd()
    at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::httpNetStatus()
    i have it working in previous version of my project, i just changed the buttons, and it stop working as i want. HELP!!!
    i apologize for my english

    i get this:
    TypeError: Error #1009: No se puede acceder a una propiedad o a un método de una referencia a un objeto nulo.
    at Popular2_fla::MainTimeline/frame1()[Popular2_fla.MainTimeline::frame1:10]
    at flash.display::MovieClip/gotoAndStop()
    at Popular2_fla::MainTimeline/completePlay()[Popular2_fla.MainTimeline::frame1:7]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.video::FLVPlayback/http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::httpDoStopAtEnd()
    at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::httpNetStatus()
    And the code in the frame is:
                        stop();
                        import fl.video.*;
                        vidPlayer.addEventListener(VideoEvent.COMPLETE, completePlay);
                        function completePlay(e:VideoEvent):void {
    Line 7: -- >    gotoAndStop(1);
    Line 10: -- >  btn1.addEventListener(MouseEvent.CLICK, vid1);
                        btn2.addEventListener(MouseEvent.CLICK, vid2);
                        btn3.addEventListener(MouseEvent.CLICK, vid3);
    function vid1(e:Event):void{
    vidPlayer.source = "hockey.flv"
    gotoAndStop(3);
    function vid2(e:Event):void{
    vidPlayer.source = "guitar.flv"
    gotoAndStop(4);
    function vid3(e:Event):void{
    vidPlayer.source = "bear.flv"
    gotoAndStop(5);

  • Help with z program output and scrollbars

    Morning all
    We are running an ERP2004 SAP system, and we're having some problems with a z program. Basically it was a quick bit of code put together to check user names against the names stored in PA.
    Now the problem is that when the report is output on a PC running its screen resolution at 1024x768, we can't see the last field output in the report and there's no horizontal scroll bar. If we run the program on a desktop with a screen resolution at 1280x1024, we can see the last column, so no need for the scrollbar and it's not output.
    Now I thought SAP added the scroll bars automatically for you if you needed them? Has anyone come across this before, because I haven't and it seems very strange indeed!

    and also u have to checl LINE-SIZE while defining the Report.
    Regards
    Prabhu

  • Help with limited acc because of withdraw

    The other day I actually managed to link my checking account attached to the prepaid debit card I got from card.com. From BanCorp, same folks who issue paypal cards. Anyways, gyft wouldn't let me buy an amazon gift card without an ID... don't have one of those, as they cost money. My friend had sent some money to help me finally get off my feet, a lovely $300. More than I'd ever seen physically. Anyways, I requested a bank transfer. This was rejected, and paypal has locked down my account because the bank said I didn't authorize it (didn't know I needed to call the bank about every little transaction that might take place...). So I went through the stuff to resolve the matter fairly quickly, until I got to proof of address. I don't have much mail, and the bit I have is from my card.com prepaid being mailed, and some from BofA as they accepted my application, and thusly canceled my account the next day. ..yeah. So paypal wants a driver's license and a utility bill. Neither of which I have because of multiple reasons, mainly poverty. My friend just wanted to help me out and first gofundme **bleep** us over and now paypal. Except I don't know if paypal will give him the money back since there's absolutely no way I can provide the information they want as my family doesn't have the means to help me get those things. Please if anyone has any suggestions, it would help incomprehensibly.. this is very depressing to be **bleep** over constantly just because I'm poor and can't have all these things..

    can anyone help..? please? this is extremely mean of paypal to do simply because i requested the money be sent so that i could actually use it.. i really dont understand how the bank or why the bank would tell them it was unauthorized.. it's just a deposit, right? nobody ever told me you have to call a bank for every single transaction i assume because it isn't actually necessary..

  • Need help with disabling the output excution command

    hey guys
    i'm doing an assignment in which user can input multiple lines. I'm using the scanner class. The problem i'm facing is that when user gives their input in multiple lines then it displays the asking input line even though it doesn't ask for new input because the pervious input stored in the memory. Please help me to disable it somehow. I understand the logic and everything but i can't find a way to disable that line. Here's my code:
    print("Please enter words to be converted into Swedish Chef or \"END\" to stop");
            inputText = input.nextLine();
            while (!inputText.equals ("END")  ) {
                // separate the text and punctuations
                removePunctuations();
                // translate all the input text
                for (int i = 0; i < inputWOP.length; i++ ) {
                   translateText(inputWOP);
    // display the translated text inculding all the punctuations
    printTranslatedText();
    System.out.println();
    /** the problem is on this line, logically it make sense that
    * this will be displayed until "END" isn't entered
    * but i want this line not to excute if there's multiple line input
    print("Please enter words to be converted into Swedish Chef or \"END\" to stop");
    inputText = input.nextLine();
    Please help me to solve this problem, thanks in advance!

    salubad,
    Do you really understand your logic? This is a classic while !EOF loop gone wrong... Examine your own code I'm sure you'll get it.
    /** the problem is on this line, //YEP
    logically it make sense that
    * this will be displayed until "END"
    isn't entered //DOES IT REALLY?
    * but i want this line not to excute if
    there's multiple line input //yep, just make it so.
    rint("Please enter words to be converted into Swedish
    Chef or \"END\" to stop");
    inputText = input.nextLine();
    Keith.

  • Help with a label output. Probably something simple.

    Don't worry about the rest of the code, my problem is that the label will not update after the btOption1 button is clicked.
    Any suggestions?
    // Create the event
        class ButtonListener implements ActionListener
            public void actionPerformed(ActionEvent e)
                if(e.getSource() == btOption1)
                    // Declare variables
                    int intTickets = 0;
                    double dblSurcharge = 0;
                    double dblTotal = 0;
                    String strNum1 = lblFName1.toString();
                    String strNum2 = lblFName2.toString();
                    String strNum3 = lblFName3.toString();
                    String strNum4 = lblFName4.toString();
                    String strOutput = "";
                    // Calculate the amount of tickets sold for the surcharge
                    intTickets = Integer.parseInt(strNum1) + Integer.parseInt(strNum2) + Integer.parseInt(strNum3) + Integer.parseInt(strNum4);
                    // Calculate the surcharge
                    dblSurcharge = 5 * intTickets;
                    // Calculate the total cost
                    dblTotal = dblSurcharge + ((Integer.parseInt(strNum1) * 7.50) + (Integer.parseInt(strNum2) * 6.25) + (Integer.parseInt(strNum3) * 8.75) + (Integer.parseInt(strNum4) * 7.50));
                    //  Convert the double to string
                    strOutput = dblTotal.toString();
                    // Display the total cost of the tickets
                    lblOutput.setText("$" + dblTotal);
        }Edited by: Anonymous23 on Jun 7, 2010 3:05 PM

    import javax.swing.*;
    import java.awt.GridLayout;
    import java.awt.event.*;
    import java.awt.*;
    public class FandangoTickets extends JFrame
        int intTickets = 0;
        int intSurcharge = 5;
        double dblTotal = 0;
        private JButton btOption1 = new JButton("Order");
        private JLabel lblImage = new JLabel(new ImageIcon("Images/Fandango.jpg"));
        private JTextField lblFName1 = new JTextField("0");
        private JTextField lblFName2 = new JTextField("0");
        private JTextField lblFName3 = new JTextField("0");
        private JTextField lblFName4 = new JTextField("0");
        private JLabel lblOutput = new JLabel("$0.00");
        public FandangoTickets()
            setLayout(new GridLayout (7,3,3,3));
            add(new JLabel("Matinee Tickets:"));
            add(new JLabel(""));
            add(new JLabel(""));
            add(new JLabel(""));
            add(new JLabel("Adult Ticket"));
            add(lblFName1);
            add(new JLabel(""));
            add(new JLabel("Child Ticket"));
            add(lblFName2);
            add(new JLabel("Evening Tickets:"));
            add(new JLabel(""));
            add(new JLabel(""));
            add(new JLabel(""));
            add(new JLabel("Adult Ticket"));
            add(lblFName3);
            add(new JLabel(""));
            add(new JLabel("Child Ticket"));
            add(lblFName4);
            add(lblImage);
            add(btOption1);
            add(lblOutput);
        class ButtonListener implements ActionListener
            public void actionPerformed(ActionEvent e)
                if(e.getSource() == btOption1)
                    String strNum1 = lblFName1.toString();
                    String strNum2 = lblFName2.toString();
                    String strNum3 = lblFName3.toString();
                    String strNum4 = lblFName4.toString();
                    String strOutput = "";
                    dblTotal = intSurcharge + ((Integer.parseInt(strNum1) * 7.50) + (Integer.parseInt(strNum2) * 6.25) + (Integer.parseInt(strNum3) * 8.75) + (Integer.parseInt(strNum4) * 7.50));
                    strOutput = Double.toString(dblTotal);
                    lblOutput.setText("$" + dblTotal);
        public static void main()
            FandangoTickets frame = new FandangoTickets();
            frame.setTitle("Fandango Tickets");
            frame.setSize(300,300);
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
    }

Maybe you are looking for

  • HP laserjet pro 200 color m251n reset

    Hello, I receved my HP Lasejet Pro 200 m251n yesterday and unfortunately we did not get a good start together. When printing colors, the colors are not aligned. I have printed a few diagnostic pages that just confirm the issue. Reading the forums I f

  • Windows 8.1 64-bit is not being installed.

    I need to upgrade my 32-bit Windows 8.1 to 64-bit Windows 8.1. My processor also does support 64-bit operating system. But when I boot it, my LCD displays a message "Out of Range". What type of problem is it? Whether is it LCD resolution problem or h

  • Can not connect to SAPRouter after OS/DB Migration

    Dear Expert, After did OS/DB migration from Solaris to HP-UX we have same problem with the saprouter. I try to connect to saprouter via SM59 (test connection) but I cannot create a connect and the error say partner not reached (host 172.31.1.34, serv

  • Re-installation of Mac OSX

    Hi All. I've had my macbook since July 2008. I have recently been having a few problems with it. I had to put in the installation discs twice within two-three weeks. Just recently I went on a weekend trip and when I came home, I turned my laptop on a

  • Re: applock and smart app lock does not work on 5.1.1

    Hi @omdavice @wantboost When turn on the sony only the red led light flashed multiple times. This could be because battery was fully drained or there was a problem with the boot. If you press the 3 buttons Power, Volume down and Volume up for about 8