Minor error in this code snippet?  Can you see it?

Following is an inner class. I think this problem is really small. Here it is:
class TotalButtonListener implements ActionListener
public void actionPerformed(ActionEvent e)
totalField.setText(Integer.toString(Integer.parseInt (quartersField.getText()) * quarterValue +
Integer.parseInt(nickelsField.getText()) * nickelValue + Integer.parseInt(dimesField.getText()) * dimeValue));
ActionListener totalListener = new TotalButtonListener();
totalAmountButton.addActionListener(totalListener);
HERE IS THE ERROR:
cannot resolve symbol
symbol : method toString (double)
location: class java.lang.Integer
totalField.setText(Integer.toString(Integer.parseInt(quartersField.getText()) * quarterValue +
^
1 error
Tool completed with exit code 1

There is no method java.lang.Integer.toString() that accepts a double as the argument.
You either want to use java.lang.Double.toString() or cast the result of your expression into an integer.
A hint: it's much easier to read and debug this sort of code when you use temporary variables, as in:
public void actionPerformed( ActionEvent e ) {
   int dimes = Integer.parseInt( dimesField.getText() );
   int nickes = Integer.parseInt( nickelsField.getText() );
   int quarters Integer.parseInt( quartersField.getText() );
   double total;
   total = ( quarters * 0.25 ) + ( dimes * 0.10 )...
   totalField.setText( total );
}And when you do it this way, Java will automatically cast the total into a String for you when setting the totalField.setText().
Don't forget, you're gonna want to check (trap) errors when the user types in a string like "hello" into the quarters field.

Similar Messages

  • Please help me with this error in this code snippet!

    Code Snippet:
    REPORT  ZMKTEST6.
    data : f1(2) type c,
           f2(2) type c,
           f3(10) type n value '12345'.
      clear: f1 with 'X',
             f2 with f1,
             f3 with '3'.
    write :/ f1 ,f2, f3.
    Process Error:
    The field "F1" must have the length 1.

    hi ,
    ther is not syntax with clear with 'X".
    but you can do one thing to get the one character.
    REPORT ZMKTEST6.
    data : f1(2) type c,
    f2(2) type c,
    f3(10) type n value '12345'.
    clear: f1 with 'X',  "Comment this
    f1 = f1+0(1).        "write this
    f2 with f1,
    f3 with '3'.
    write :/ f1 ,f2, f3.
    now f1 containd one charater instead of 2.
    now you can display as usuall

  • My MB Pro is no longer syncing my iPad in iTunes. It did in the beginning, however I had to change my MB Pro password. Now I get a permissions error message trying to sync: "error storing your authorization information on this computer." Can you help?

    My MB Pro is no longer syncing my iPad in iTunes. It did in the beginning, however I had to change my MB Pro password. Now I get a permissions error message trying to sync: "error storing your authorization information on this computer." Can you help?

    First I would just try deleting the SCInfo folder, restart your computer, open itunes and see if you are still getting the error, at that point if you are it is a permissions error with the computer specificaly and not in itunes.
    http://support.apple.com/kb/TS1389
    that is for deleting the scinfo folder. scroll to the bottom of the article and the steps are there

  • Hello I Download Adobe Photoshop CC 2014 Last Night i INSTALLED it But it Crashes in 30-40 Sec After i Launch the Product Without Any Error Message I Need Help Can You Resolve This Problem i Tried Creative Cloud Sign Out Nd Sign iN But iT DidnT ReSolve My

    Hello I Download Adobe Photoshop CC 2014 Last Night
     i INSTALLED it But it Crashes in 30-40 Sec After i Launch the Product Without Any Error Message
    I Need Help Can You Resolve This Problem

    Lotfi are you receiving any error messages during the installation?  I would recommend reviewing your installation logs for errors.  Please see Troubleshoot install issues with log files | CC - http://helpx.adobe.com/creative-cloud/kb/troubleshoot-install-logs-cc.html for information on how to locate and interpret your installation log files.  You are welcome to post any specific errors you discover to this discussion.

  • Hello , I'm having failed the Creative Cloud Desktop installation ( error code 1 ) . can you help me?

    Hello , I'm having failed the Creative Cloud Desktop installation ( error code 1 ) . can you help me?

    Error: "Failed to install" | Creative Cloud Desktop

  • Serial port control -- what's this code snippet?

    Hi, all.
    I've just become active working with LabView, version 6.0i. And this because of a program which "suddenly" stopped working, with no changes made by anyone that I can see (yeah, likely story, right?).
    In short, the screenshot which I'll include with this post is of one tiny code snippet buried deeply in the .vi which runs an X-Z positioning system. I'd like to know what people thing this code snippet does. I have my suspicions, but I can't believe that whoever wrote this code actually used it for this purpose!
    The X- and Z-positioners which I'm using are controlled by separate power sources, and separate ports on the computer. The X-positioner is ultra-fine-resolution, and has an optical encoder. It's controlled by the RS-232 port on the computer, and it's meant to be moved only a little at a time. The Z-positioner is a bit more coarse, and usually moves quite a bit at a time. It's serial-port controlled.
    The screenshot is of the portion of the code called "XMove" -- that portion of the code which controls the x-positioning stepper motor. Often, the Z-positioner is still running during this part of the code (the "ZMove" subroutine is called before the "XMove"), and then, after both parts of the positioner have stopped, the code should shut down the power to them, and update the position of the translation stage.
    However, once the code gets to this portion (screenshot), that while loop just keeps running.
    Here's what I think is happening (please correct me if I'm wrong!): The Z-positioner is run by the serial port, which, as far as I know, can be controlled by only one device at a time. Thus, this While loop does the following:
    1) attempts to write the characters "1R" followed by a linefeed to port 0 (the applicable serial port on this computer);
    2) reads how many characters are stored in the serial buffer;
    3) reads all the characters in the serial buffer;
    4) takes the first two characters from the string read;
    5) compares these two characters to *R;
    6) if the two characters are R, then the loop terminates and the code finishes.
    As far as I can tell (I've probed many parts of this structure), the code fails when the "N" portion passes the number of characters in the serial buffer to the "R" portion -- it's always zero. It appears to me that the "W" portion writes to the buffer AFTER the number of characters is read (I wouldn't have suspected this unless I'd run it many times and monitored which steps were done in which order). This ain't right!
    I found a similar question answered in the KnowledgeBase forum, but the answer to that one was that the serial port may have an "echo" mode. That doesn't change the fact that data is being from to the port before it's written, does it?
    Is there a way to make sure that the "read" statement happens AFTER the "write" statement? Am I way off base with what this code snippet should do? And, most importantly, *** is this a good way to tell if the Z-positioner is done with its job? ***. Is this a standard trick to tell if a program is done with the serial port?
    Thanks, all. I know the quandary of trying to debug with so few details, and not having the program in front of you. Any help is appreciated!
    Sincerely,
    Curtis Osterhoudt
    Attachments:
    VI_diagram.jpg ‏17 KB

    I suspect someone did change it, but they just don't realize they did.
    THe code snippet is an example of some very bad LV code! What you suspect is happeneing is indeed true. LV uses a data dependacy paradigm that says code execution order is dependent on data availablility. Data availability is determined by ythe rule that the output of a node or sub-VI is not available until the object completes.
    In you snipet, the only node that has to complete before the read bytes at port and the write to port VI is the the constant port number constant. That means that LV can execute either the write or the check bytes at port VI's first. This is determined at LV compile time. If for some reason LV decideds to compile in the write before the check bytes at port, the
    n the I/O may work as intended, BUT NOT POROGRAMMED!
    For a quick fix, put the contant port number and the write VI in a single frame sequence structure. This way the read from the constant and wire operation must comlplete before the seq completes, therby forcing the read stuff to wait.
    I hope this help,
    Ben
    Ben Rayner
    Certified LabVIEW Developer
    www.DSAutomation.com
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • RUN TIME ERROR IN THIS CODE

    HELLO EVERY ONE ...
    I AM GETTING run time error in this code.....can u send me the corrected code....
    START-OF-SELECTION.
    SELECT T1~MATNR
           T1~MEINS
           T1~ERSDA
           T1~ERNAM
           T1~SPART
           T2~MAKTX
           T3~LVORM
           T3~EKGRP
           T3~WERKS
           T4~LABST
           T4~SPEME
           T4~LGORT
           INTO CORRESPONDING FIELDS OF TABLE ITAB
           FROM MARA AS T1
           INNER JOIN MAKT AS T2
           ON T1MATNR = T2MATNR
           INNER JOIN MARC AS T3
           ON T2MATNR = T3NFMAT
           INNER JOIN MARD AS T4
           ON T3MATNR = T4MATNR
           WHERE T1~MATNR IN SMATNR.
    Thanx & Regards,
    PHANINDER

    ok i am sending u the full code.....
    REPORT  Z_SB_RP_MATERIAL.
    TABLES: MARA,
            MARD,
            MAKT,
            MARC,
            EINA,
            EINE.
    DATA: BEGIN OF ITAB OCCURS 15,
          MATNR LIKE MARA-MATNR,
          MEINS LIKE MARA-MEINS,
          ERSDA LIKE MARA-ERSDA,
          ERNAM LIKE MARA-ERNAM,
          SPART LIKE MARA-SPART,
          MAKTX LIKE MAKT-MAKTX,
          LVORM LIKE MARC-LVORM,
          EKGRP LIKE MARC-EKGRP,
          WERKS LIKE MARC-WERKS,
          LABST LIKE MARD-LABST,
          SPEME LIKE MARD-SPEME,
          LGORT LIKE MARD-SPEME,
          END OF ITAB.
    SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-T01.
    SELECT-OPTIONS: SMATNR FOR MARA-MATNR,
                    SERSDA FOR MARA-ERSDA,
                    SWERKS FOR MARC-WERKS,
                    SLGORT FOR MARD-LGORT.
    SELECTION-SCREEN END OF BLOCK BLK.
    TOP-OF-PAGE.
    WRITE:/ SY-VLINE,
          02 'S.NO',
          06 SY-VLINE,
          08 'MATNR',
          20 SY-VLINE,
          22 'MEINS',
          32 SY-VLINE,
          34 'ERSDA',
          44 SY-VLINE,
          46 'ERNAM',
          56 SY-VLINE,
          58 'SPART',
          68 SY-VLINE,
          70 'MAKTX',
          80 SY-VLINE,
          82 'LVORM',
          92 SY-VLINE,
          94 'EKGRP',
         104 SY-VLINE,
         106 'WERKS',
         116 SY-VLINE,
         118 'LABST',
         128 SY-VLINE,
         130 'SPEME',
         140 SY-VLINE,
         142 'LGORT',
         152 SY-VLINE.
    START-OF-SELECTION.
    SELECT T1~MATNR
           T1~MEINS
           T1~ERSDA
           T1~ERNAM
           T1~SPART
           T2~MAKTX
           T3~LVORM
           T3~EKGRP
           T3~WERKS
           T4~LABST
           T4~SPEME
           T4~LGORT
           INTO CORRESPONDING FIELDS OF TABLE ITAB
           FROM MARA AS T1
           INNER JOIN MAKT AS T2
           ON T1MATNR = T2MATNR
           INNER JOIN MARC AS T3
           ON T2MATNR = T3NFMAT
           INNER JOIN MARD AS T4
           ON T3MATNR = T4MATNR
           WHERE T1~MATNR IN SMATNR.
    END-OF-SELECTION.
    DATA: COUNT(4) TYPE N.
    LOOP AT ITAB.
    COUNT = COUNT + 1.
      WRITE:/ SY-VLINE,
          02 COUNT,
          06 SY-VLINE,
          08 ITAB-MATNR,
          20 SY-VLINE,
          22 ITAB-MEINS,
          32 SY-VLINE,
          34 ITAB-ERSDA,
          44 SY-VLINE,
          46 ITAB-ERNAM,
          56 SY-VLINE,
          58 ITAB-SPART,
          68 SY-VLINE,
          70 ITAB-MAKTX,
          80 SY-VLINE,
          82 ITAB-LVORM,
          92 SY-VLINE,
          94 ITAB-EKGRP,
         104 SY-VLINE,
         106 ITAB-WERKS,
         116 SY-VLINE,
         118 ITAB-LABST,
         128 SY-VLINE,
         130 ITAB-SPEME,
         140 SY-VLINE,
         142 ITAB-LGORT,
         152 SY-VLINE.
    ENDLOOP.
    THANX & REGARDS,
    PHANINDER

  • I've used Project Web App on Sharepoint 2013. After clear job queue about force check-in then I've got this error. This made me can't access some pages in PWA anymore e.g. Project center, Resoure center, PWA setting, etc.

    I've used Project Web App on Sharepoint 2013. After clear job queue about force check-in then I've got this error. This made me can't access some pages in PWA anymore e.g. Project center, Resoure center, PWA setting, etc.  Who have ever found this problem,
    pls. help.
    The pop up error msg. is "Sorry, you don't have access to this page"

    Hi,
    According to your description, after you cleared job queue about force check-in then you can't access some pages in PWA.
    Maybe you need to check in the pages which has been checked out.
    If you have administrative rights, it is possible to override the check-out via the View All Site Content page:
    Site Actions->View All Site Content->Pages->Hover the item you want to check in, and from the context-menu (arrow-down next to the filename), choose "Discard Check Out"
    Besides, to troubleshooting the error “Sorry, you don't have access to this page”, refer to the following articles:
    http://sharepoint.rackspace.com/sharepoint-2013-troubleshooting-an-access-issue-with-a-custom-master-page
    http://technet.microsoft.com/en-us/library/ff758656(v=office.15).aspx
    In addition, as this issue is related to project server, I suggest you create a new thread on project server, more experts will assist you:
    https://social.technet.microsoft.com/Forums/projectserver/en-US/home?category=project
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • HT4847 I can not delete old icloud back up from my old phone, keep receiving an error message "this back up can not be deleted because it's in use" it is not in use that phone is long gone!

    I can not delete old icloud back up from my old phone, keep receiving an error message "this back up can not be deleted because it's in use" it is not in use that phone is long gone!

    I have the same problem here and it wont let me do another back up or delete the old one.... Please help!!!! Anyone

  • I had a repair done on my MacBook Pro and had to have a new hard drive installed. The Apple Auth Repair Shop then updated the OS from 10.6.8 to 10.7.5. Now my iPhoto v 9.2.3 will not open and it sounds like it will not work with this OS. Can you plea

    I had a repair done on my MacBook Pro and had to have a new hard drive installed. The Apple Auth Repair Shop then updated the OS from 10.6.8 to 10.7.5. Now my iPhoto v 9.2.3 will not open and it sounds like it will not work with this OS. Can you please advise?

    You may need many other updates to retain compatibility with Lion. I suggest you reinstall Snow Leopard. Unfortunately, you will need to erase the drive first. Be sure to backup your data if you haven't done so already.
    Clean Install of Snow Leopard
    Be sure to make a backup first because the following procedure will erase
    the drive and everything on it.
         1. Boot the computer using the Snow Leopard Installer Disc or the Disc 1 that came
             with your computer.  Insert the disc into the optical drive and restart the computer.
             After the chime press and hold down the  "C" key.  Release the key when you see
             a small spinning gear appear below the dark gray Apple logo.
         2. After the installer loads select your language and click on the Continue
             button. When the menu bar appears select Disk Utility from the Utilities menu.
             After DU loads select the hard drive entry from the left side list (mfgr.'s ID and drive
             size.)  Click on the Partition tab in the DU main window.  Set the number of
             partitions to one (1) from the Partitions drop down menu, click on Options button
             and select GUID, click on OK, then set the format type to MacOS Extended
             (Journaled, if supported), then click on the Apply button.
         3. When the formatting has completed quit DU and return to the installer.  Proceed
             with the OS X installation and follow the directions included with the installer.
         4. When the installation has completed your computer will Restart into the Setup
             Assistant. After you finish Setup Assistant will complete the installation after which
             you will be running a fresh install of OS X.  You can now begin the update process
             by opening Software Update and installing all recommended updates to bring your
             installation current.
    Download and install Mac OS X 10.6.8 Update Combo v1.1.

  • I installed Adobe Photoshop Elements 11 in my computer before. Right now I'm not using that computer anymore and want to re-install the software to a new computer. I still have the redemption code. Can you please provide me the download link or which ever

    I installed Adobe Photoshop Elements 11 in my computer before. Right now I'm not using that computer anymore and want to re-install the software to a new computer. I still have the redemption code. Can you please provide me the download link or which ever way I can re-install the software to the new computer? Thank you.

    Hi,
    Please go to the link below to download Photoshop elements 11
    http://helpx.adobe.com/photoshop-elements/kb/photoshop-elements-10-11-downloads.html
    To get your serial number from redemption code click on the link below
    https://redeem.licenses.adobe.com/getserial/s/redeem
    Thank you,
    Mohd. Naseem

  • I have Iphone 4G. I bought when I studied in Usa. Then I returned to  Uzbekistan this Iphone doesn't work. How I can use this phone? Can you help me?

    I have Iphone 4G. I bought when I studied in Usa. Then I returned to  Uzbekistan this Iphone doesn't work. How I can use this phone? Can you help me?

    shohjahon wrote:
    I have Iphone 4G.
    No, you do not.  It simply is not possible to have a device that does not exist.
    Most likely, you have an iPhone 4.  There is no 4G iPhone.
    shohjahon wrote:
    I bought when I studied in Usa. Then I returned to  Uzbekistan this Iphone doesn't work.
    Yes, it does work.  It is carrier locked to AT&T, just like all GSM iPhones sold in the US since their introduction.
    shohjahon wrote:
    How I can use this phone?
    You can use the phone as it is, but it will be very expensive with AT&T international roaming plans.
    There is no official way to unlock the phone for use with another carrier.
    Your options:
    Sell the device and purchase one intended for use in your country.
    Find unofficial method to unlock
    Use as an iPod Touch.
    No one here can provide you with assistance on getting you AT&T locked iPhone to work on another carrier.

  • I have purchased a new Mac power book 10.9.2.  I cannot open illustrator CS4 and get the error message 150:30.  Can you help?

    I have purchased a new Mac power book 10.9.2.  I cannot open adobe illustrator CS4 and get the error message 150:30.  Can you help?

    You are welcome, Sharon.
    You should be aware that the newest version, CC, is only available as a subscription.
    CS6 can be purchased at Adobe, or second hand, see below.
    Older versions such as CS5 can only be bought second hand, with a licence transfer through Adobe, requiring that the licence has not been used as a basis for an upgrade.

  • I can't Import .tif in illustrator CS4 anymore since Yosemite. Someone have this problem ? Can you help me please ?

    I can't Import .tif in illustrator CS4 anymore since Yosemite. Someone have this problem ? Can you help me please ?

    Pat,
    Did you reinstall after updating to Yoesmite?
    If not, you could try to reinstall using the full three step way, and see whether things work.
    Uninstall, run the Cleaner Tool, and reinstall.
    http://www.adobe.com/support/contact/cscleanertool.html

  • When I startup Itunes I get "An Unknown Error Occurred -42110" Message.  Can you tell me what is wrong and how to resolve?

    When I startup Itunes I get "An Unknown Error Occurred -42110" Message.  Can you tell me what is wrong and how to resolve?

    Try the following user tip:
    iTunes for Windows 11.0.2.25 and 11.0.2.26: "Unknown error -42110" messages when launching iTunes

Maybe you are looking for

  • Lollipop update is a mixed bag

     So I just got Lollipop on my Z1C and had alot of expectations. Sadly it has more downsides for me at the moment. The interface is pretty inconsistent and the white color ... oh my god I need to wear sunglasses now when operating on my phone. The aut

  • Any Video Monitoring Standards in NLEs?

    Something that's been talked about lately in another forum I attend is that the preview window in Sony Vegas has about 10% less contrast compared to... well just about any other NLE out there including CS5. Here's an image that was posted on a blog s

  • Reference external library movieclip in library with AS3

    Hello, i am able to load at runtime a library asset in flash cs3. i do this by setting up its linkage property and setting its base class. for eg Class: MyButton Base: flash.display.MovieClip then in my document class, say i had com.kofi.InitializeTe

  • Whether I'm in Mail or downloading from YouTube or the internet, lately I'm getting a message "Plug-in Failed".  What can I do?

    Whether I'm in Mail or downloading from YouTube or the internet, lately I'm getting a message "Plug-in Failed".  What can I do?

  • Statistical Setup Query

    How do you determine or calculate the time which would be taken to fill the Setup tables? Is it based on the number of records in the DB tables or something else? Suppose somebody says it would take about 10 hours to fill the Setup tables, on what ba