Errors in my temperature converter

Today I am playing with a class that converts Fahrenheit to Celsius. I understand that the formula for Fahrenheit to Celsius is: (5/9)*(deg F-32)
Here is my class:
import javax.swing.JOptionPane;
public class TConverter {
     public static void main(String[] args) {
          double Fahrenheit=98.6;
          double Celsius=(5/9)*(Fahrenheit-32);
          JOptionPane.showMessageDialog(null,Celsius);
I have two problems:
1) the result I get is always 0. Why?
2) I get an error on the line:
JOptionPane.showMessageDialog(null, Celsius);unless I enter some type of string:
JOptionPane.showMessageDialog(null, "Celsius: " + Celsius);Does that mean that in JOptionPane.showMessageDialog I must always have a string to be able to use it?
Message was edited by:
Lavazza

1) the result I get is always 0. Why?
The error is that the division 5/9 is evaluated as a division between integer... so you have to explictilly specify a cast to double in order to not obtain 0
2) I get an error on the line:
JOptionPane.showMessageDialog(null,
Celsius);unless I enter some type of string:
JOptionPane.showMessageDialog(null, "Celsius:
" + Celsius);Does that mean that in JOptionPane.showMessageDialog
I must always have a string to be able to use it?
The problem is that the method showMessageDialog accept (you can see documentation) an Object like second parameter... and double is not an Object but it's a primitive type. Convert it to an object using the utility class Double.
Belowe I put the right implementation.
Bye
Diego
import javax.swing.JOptionPane;
public class TConverter {
     public static void main(String[] args) {
          double Fahrenheit=98.6;
          double Celsius= ((double)5/9)*(Fahrenheit-32);
          JOptionPane.showMessageDialog(null,new Double(Celsius));
}

Similar Messages

  • Error when trying to convert excel files to pdf

    I'm getting the following error when trying to convert .xls and .xlsx files to pdf, using the "Create PDF" option:
    Error message from the primary converter:
    ALC-PDG-010-012-PDFMaker reported an error while printing the document.
    Word, Powerpoint and Text files convert without any issues. Also I'm able to opent the excel files and convert them to pdf using the acrobat option in excel.
    Livecycle Version: 10.0.2, GM
    MS Office Version: 2007
    Any help would be appreciated. Thanks in advance.
    Regards,
    Suhail N.

    It is always difficult when you need to convert multiple xls files to pdf or multiple sheets to pdf. If you have a single file to convert then the best method would be to copy your data to doc file and then convert it into PDF . If you have multiple files to convert then it is really difficult to convert all the files manually. Then the better method would be to use converter tool to convert excel to pdf . By doing this you can convert many files in just few seconds.

  • I'm getting a 9041 error when trying to convert files to AAC -- any ideas on how to fix it?  the files files in iTunes show up as Apple Lossless but i can't put them on my iPod

    i'm getting a 9041 error when trying to convert files to AAC -- any ideas on how to fix it?  the files files in iTunes show up as Apple Lossless but i can't put them on my iPod

    "I have been able to convert to AAC by first converting to AIFF  and then to AAC. This is a pan though."
    this worked for me.
    thanks.

  • Error Message in Word  Convert To PDF Tab

    I am gettting an Error Message in Word  Convert To PDF Tab
    The pop up box comes up when I am in Word 2003 , it says "Unabkle To Find PDFresource files, you must be an adminstrator to install these files
    So I cannot create a PDF file when in Word 2003
    When I go to Acrobat  9.0 and try to create from a file , choose the word file, it says it is creating it- but nothing happens, its like it's not loading.
    I am on a PC

    Can you print to the Adobe PDF printer (I suspect you can not)? Are you logged in as the administrator? Can you find any of the job settings files? If the latter is the case, then you likely do not have permissions set to allow you to read the folder that has all the job settings. If you are not the administrator, you will have to get the administrator to find the folder (it is in one of the document and settings folders under Adobe for XP and under the Users (I think) on Win7) and grant you access.

  • Problems converting PDF to MS Word document.  I successfuly converted 4 files and now subsequent files generate a "conversion failure" error when attempting to convert the file.  I have a large manuscript and I separated each chapter to assist with the co

    Problems converting PDF to MS Word document.  I successfully converted 4 files and now subsequent files generate a "conversion failure" error when attempting to convert the file.  I have a large manuscript and I separated each chapter to assist with the conversion; like I said, first 4 parts no problem, then conversion failure.  I attempted to convert the entire document and same result.  I specifically purchased the export to Word feature.  Please assist.  I initially had to export the Word Perfect document into PDF and attempting to go from PDF to MS Word.

    Hi sdr2014,
    I'm sorry to hear your conversion process has stalled. It sounds as though the problem isn't specific to one file, as you've been unable to convert anything since the first four chapters converted successfully.
    So, let's try this:
    If you're converting via the ExportPDF website, please log out, clear the browser cache, and then log back in. If you're using Reader, please choose Help > Check for Updates to make sure that you have the most current version installed.
    Please let us know how it goes.
    Best,
    Sara

  • Error:Type mismatch: cannot convert from Long to Long

    hi friends,
    I've a problem.I've a JSP that does some long converions,and its working fine when i make it run on my machine i.e
    (Running Tomcat5.0),but when I deploy this file on the server which runs Tomcat 5.5.7,it throws this error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 20 in the jsp file: /abc.jsp
    Generated servlet error:
    Type mismatch: cannot convert from Long to Long
    Can anyone of you,tell me where i am going wrong???

    Here is an example of doing it with a JavaBean... the bean looks like this:
    package net.thelukes.steven;
    import java.io.Serializable;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class FormHandlerBean implements Serializable {
         private static final long serialVersionUID = 1L;
         private Date startTime = null;
         private DateFormat dateFormatter;
         public FormHandlerBean() {
              setDateFormat("yyyy-MM-dd hh:mm:ss");
         public void setStart(String strt) {
              setStartAsString(strt);
         private void setStartAsString(String strt) {
              setStartAsDate(getDate(strt));
         private void setStartAsDate(Date d) {
              startTime = d;
         private Date getDate(String s) {
              Date d = null;
                   try {
                        d = dateFormatter.parse(s);
                   } catch (ParseException pe) {
                        System.err.print("Error Parsing Date for "+s);
                        System.err.println(".  Using default date (right now)");
                        pe.printStackTrace(System.err);
                        d = new Date();
              return d;
         public long getStartAsLong() {
              return getStart().getTime();
         public String getStartAsString() {
              return Long.toString(getStartAsLong());
         public Date getStart() {
              return startTime;
         public void setDateFormat(String format) {
              dateFormatter = new SimpleDateFormat(format);
    }You would only need to make the getStartXXX methods public that need to be accessed from the JSP. For example, if you will not need to get the Long value of the time, then you do not need to make getStartAsLong public...
    The JSP looks like this:
    <html>
      <head>
        <title>I got the Form</title>
      </head>
      <body>
        <h3>The Output</h3>
        <jsp:useBean class="net.thelukes.steven.FormHandlerBean" id="formHandler"/>
        <%
             formHandler.setStart(request.getParameter("start"));
        %>
        <table>
          <tr><td>Start as String</td><td><jsp:getProperty name="formHandler" property="startAsString"/></td></tr>
          <tr><td>Start as Date</td><td><jsp:getProperty name="formHandler" property="start"/></td></tr>
          <tr><td>Start as long</td><td><jsp:getProperty name="formHandler" property="startAsLong"/></td></tr>
        </table>
      </body>
    </html>If this were a servlet processing the form rather than a JSP, I might throw the ParseException that might occur in getDate and catch it in the Servlet, with which I could then forward back to the form telling the user they entered mis-formatted text value... But since JSPs should be mainly display, I catch the exception internally in the Bean and assign a safe value...

  • HelloClient.cpp(36) : error C2440: 'initializing' : cannot convert from 'class CORBA_WStringValue *' to '

    "HelloClient.cpp(36) : error C2440: 'initializing' : cannot convert from 'class CORBA_WStringValue *' to 'const char *'"Hi I am getting this error when I try toprint the value which I am getting fromthe RMI Implementation class.Thanks.

    What orb are you using in the client?
    LP wrote:
    "HelloClient.cpp(36) : error C2440: 'initializing' : cannot convert from 'class CORBA_WStringValue *' to 'const char *'"Hi I am getting this error when I try toprint the value which I am getting fromthe RMI Implementation class.Thanks.

  • I receive an error when trying to convert PDF to word.  Pls help, I have a paid acct.

    I receive an error when trying to convert PDF to word.  Can someone advise on how to resolve?

    "an error" really doesn't tell us much.
    Assuming that you use the ExportPDF online service, I suggest that you Contact Customer Care - click on the Still need help? button to chat or talk with an agent.
    [topic moved to ExportPDF forum]

  • Please help.  Keep getting a conversion error when trying to convert a PDF to a .docx. Advice?

    Please help.  Keep getting a conversion error when trying to convert a PDF to a .docx. Advice?

    Sara,
    Please see my answers in bold below.
    What browser are you using? Try clearing the cache, or using a different browser. N/A
    Are you converting from within Reader, or directly via the ExportPDF website. Within Reader.I disabled the OCR and this did not work either. Try converting from within Reader, and disable OCR as detailed in this document: How to disable Optical Character Recognition (OCR) when converting PDF to Word or Excel.
    Are you on a networked computer? Make sure that there aren't any firewall/proxy settings that are preventing you from uploading files to the Internet. Not having problems uploading the file--that works fine.
    Make sure the file is within the file-size limit of 100 MB. It is <40.
    I get the error message, "File failed to be converted using Adobe ExportPDF online."
    Thanks for your help in advance.

  • Envy 5534 on MAC- print error message unable to convert post scrip file

    New printer set up fine prints letter but when I want it to print a page with bar code on get error message :-
    print error message unable to convert post scrip file
    Can any one help please
    This question was solved.
    View Solution.

    Hi @itsalex,
    What type of bar code are you printing, and from what program? Just a thought, what if you print the barcode as an image, if you are not already? Try File>Print> Advanced> Print as Image> print.
    If the issue persists, let's reset the printing system and repair the disk permissions; doing so may resolve the issue.
    Reset Printing System
    Click the Apple icon ( ), and then click System Preferences.
    In the Hardware section, click Print & Fax/Scan. The Print & Fax/Scan dialog box opens.
    Right-click (or Ctrl +click) in the left panel, and then click Reset printing system…
    Click OK to confirm the reset.
    Type the correct Name and Password.
    Click OK to reset the printing system. The Print & Fax dialog box shows no printer selected
    Note: This will remove all printers in the print and Fax/Scan, any printer removed can be re-added later by clicking the plus (+) symbol.
    Repair Disk Permissions
    On the Dock, click Applications, and then click Utilities.
    Double-click Disk Utility.
    Highlight your hard drive/partition on the left (by default this is "Macintosh HD").
    Click the Repair Disk Permissions button at the bottom of the window.
    Once the repair is complete, restart the computer and add the printer back.
    When you add the printer, please ensure you are using the HP driver.
    Select Add other Printer or Scanner 
    Select the printer you are adding and next to 'Use' you can select the printer drive. In the screenshot below, you will see Airprint is auto selected, you can change it to the HP driver though.
    I look forward to hearing back from you.
      Talk to you later alligator 
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • Program: /SAPAPO/CLP_PBEXCHANGE; error: Selection Cannot be Converted

    Hello,
    when running program /SAPAPO/CLP_PBEXCHANGE I am getting the error Selection Cannot be Converted
    Message no. APO_BAPI408 ...
    I assume that this was caused by a SP upgrade of the sending system (APO 50 SP13) ... as before we haven't had any issue in this area.
    Does anybody have any idea ... what might have changed or whether somewhere a parameter is missing.
    Thanks in advance.
    Regards,
    Andi

    REPORT  Z_1480178.
    data : lt_secresid     TYPE  /sapapo/om_resid_tab,
          lt_sec_res      TYPE /sapapo/pt_secres_tab.
    CALL FUNCTION '/SAPAPO/RRP_PT_RES_GET_SECRES'
      EXPORTING
        iv_simid   = '000'
        it_resid   = 'GxAp7t6MCllX00002X5EvG'
      IMPORTING
        et_sec_res = lt_sec_res.
    move-corresponding lt_sec_res to lt_secresid.
    changed the code as follows...
    but still get the error lt_sec_res is not a structure or internal table with header line

  • ADADMIN ERROR WHILE RUNNING MRC CONVERT IN ADADMIN ORA-04021

    제품 : AOL
    작성날짜 : 2002-11-29
    ADADMIN ERROR WHILE RUNNING MRC CONVERT IN ADADMIN ORA-04021
    ============================================================
    Problem description:
    MRC convert를 위해 adadmin을 돌리던 도중 다음의
    에러 발생
    old 1: GRANT EXECUTE ON dbms_aq TO &3
    new 1: GRANT EXECUTE ON dbms_aq TO APPS_MRC
    GRANT EXECUTE ON dbms_aq TO APPS_MRC
    ERROR at line 1:
    ORA-04021: timeout occurred while waiting to lock object SYS.DBMS_AQ
    PURPOSE
    Problem Description
    Workaround
    invalid synonym WSH_SSWA_OPTIONS을 다음의 command를 사용하여
    drop한다:
    sqlplus apps/<apps_passwd>
    SQL> drop synonym WSH_SSWA_OPTIONS;
    Synonym dropped.
    Solution Description
    Customers who want to install MRC have to clean up the Validate Apps report.
    MRC를 install하기 원할경우 Validate Apps report를 먼저 clean up해야 한다. 그렇기 때문에 adadmin에서 "Convert to Multiple Reporting Currencies"
    를 돌리기전에 "Validate APPS schema(s)"을 돌려서 에러들을 clean up 해야만한다.
    Reference Documents
    Note:135756.1
    Note:185151.1

    제품 : AOL
    작성날짜 : 2002-11-29
    ADADMIN ERROR WHILE RUNNING MRC CONVERT IN ADADMIN ORA-04021
    ============================================================
    Problem description:
    MRC convert를 위해 adadmin을 돌리던 도중 다음의
    에러 발생
    old 1: GRANT EXECUTE ON dbms_aq TO &3
    new 1: GRANT EXECUTE ON dbms_aq TO APPS_MRC
    GRANT EXECUTE ON dbms_aq TO APPS_MRC
    ERROR at line 1:
    ORA-04021: timeout occurred while waiting to lock object SYS.DBMS_AQ
    PURPOSE
    Problem Description
    Workaround
    invalid synonym WSH_SSWA_OPTIONS을 다음의 command를 사용하여
    drop한다:
    sqlplus apps/<apps_passwd>
    SQL> drop synonym WSH_SSWA_OPTIONS;
    Synonym dropped.
    Solution Description
    Customers who want to install MRC have to clean up the Validate Apps report.
    MRC를 install하기 원할경우 Validate Apps report를 먼저 clean up해야 한다. 그렇기 때문에 adadmin에서 "Convert to Multiple Reporting Currencies"
    를 돌리기전에 "Validate APPS schema(s)"을 돌려서 에러들을 clean up 해야만한다.
    Reference Documents
    Note:135756.1
    Note:185151.1

  • Error message:can't convert int to int[]

    Hi,
    I am trying to build a java code which convert decimal to binary
    but ,I found error message "can not convert int to int[]"
    some line of code:
    int i=12,n=0;
    int arr[n]=i%2;
    n++;
    here I am trying to store remainder in an integer arrary.
    how can i do this???????
    guide me please
    -shobhit singh

    shobhit_onprob wrote:
    i want to store some integer values in to an integer arraryDid you follow the address that was given to you? I doubt it, and even if you did, 2 minutes is not enough time to read, let alone understand, the tutorial.
    Go back there, it describes all the basics you need.

  • Error when starting a converted VM (from vmware server edition)

    Hi, i am trying to start a converted VM from VMWARE SERVER. I think i have followed steps to import an VMWARE machine (using resources >> virtual machines images) and it does not return errors when converting VM but then, when trying to start it, it returns
    failed:<OVSException: no server selected to run vm('/OVS/running_pool/SIR_xxx') memory=512> StackTrace: File "/opt/ovs-agent-2.2/OVSSiteVM.py", line 77, in start_vm raise e
    I have also checked that there is enough memory.
    This is the contect for vm.cfg
    acpi = 1
    apic = 1
    builder = 'hvm'
    device_model = '/usr/lib/xen/bin/qemu-dm'
    disk = ['file:/OVS/running_pool/SIR_xxx/SIR_xxx.img,hda,w',
    'file:/OVS/running_pool/SIR_consulnor/SIR_xxx (2).img,hdb,w',
    ',hdc:cdrom,r',
    kernel = '/usr/lib/xen/boot/hvmloader'
    memory = '512'
    name = 'SIR_xxx'
    on_crash = 'restart'
    on_reboot = 'restart'
    pae = 1
    serial = 'pty'
    timer_mode = '1'
    uuid = 'e23767cc-dc3d-0255-a7ac-65f111b589d7'
    vcpus = 1
    vif = ['bridge=xenbr0,mac=00:16:3E:71:AF:B1,type=ioemu']
    vif_other_config = []
    vnc = 1
    vncconsole = 1
    vnclisten = '0.0.0.0'
    vncpasswd = 'xxx'
    vncunused = 1
    Thanks for your help

    user559432 wrote:
    failed:<OVSException: no server selected to run vm('/OVS/running_pool/SIR_xxx') memory=512> StackTrace: File "/opt/ovs-agent-2.2/OVSSiteVM.py", line 77, in start_vm raise eDo your servers have Hardware/Full Virtualization enabled? You can check on the console and ensure the console says that Hardware Virtualization is enabled. If not, check in your BIOS that the processor hardware virtualization is enabled. If you don't have an option, your PC may not have the Intel VT-x or AMD-v extensions required to support hardware virtualization.
    You can check to see if your processor supports this extension by using:
    Intel processor:
    # cat /proc/cpuinfo | grep vmxAMD processor:
    # cat /proc/cpuinfo | grep svmIf you see a result, it means the processor has that support. You still need to ensure that it is enabled in the BIOS.

  • Runtime error while trying to convert script to pdf and sending in mail

    Hi all,
    I m trying to convert the standard script into pdf using convert_otf fm and trying to send it as an attachment using 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
    I m using fm 'SSF_FUNCTION_MODULE_NAME' to get the function module name.
    But i m getting a runtime error while executing the program..
    Can anyone help me in this issue please.
    Thanks in advance,
    Ashok

    Hi Ramesh,
    I m getting an runtime error function module not found. I ll paste the code here.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = lf_formname
        IMPORTING
          fm_name            = lf_fm_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc = 0.
    error handling ent_retco = sy-subrc.
    perform protocol_update_i.
      ENDIF.
      ls_control_param-getotf = 'X'.
      DATA: l_document_output_info TYPE ssfcrespd,
            l_job_output_info TYPE ssfcrescl,
            l_job_output_options TYPE ssfcresop.
    check ent_retco eq 0.
      CALL FUNCTION 'lf_fm_name'
      EXPORTING
        archive_index = toa_dara
        archive_parameters = arc_params
        control_parameters = ls_control_param
        mail_recipient = ls_recipient
        mail_sender = ls_sender
        output_options = ls_composer_param
        user_settings = ' '
        zxekko = l_doc-xekko
        zxpekko = l_doc-xpekko
    zxaend = l_doc-xaend
        IMPORTING
          document_output_info = l_document_output_info
          job_output_info = l_job_output_info
          job_output_options = l_job_output_options
          TABLES
            l_xekpo = l_doc-xekpo[]
            l_xekpa = l_doc-xekpa[]
            l_xpekpo = l_doc-xpekpo[]
            l_xeket = l_doc-xeket[]
            l_xtkomv = l_doc-xtkomv[]
            l_xekkn = l_doc-xekkn[]
            l_xekek = l_doc-xekek[]
            l_xaend = l_doc-xaend[]
            l_xkomk = l_xkomk
            EXCEPTIONS
              formatting_error = 1
              internal_error = 2
              send_error = 3
              user_canceled = 4
              OTHERS = 5.
    CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
        IMPORTING
          bin_filesize          = v_len_in
        TABLES
          otf                   = l_job_output_info-otfdata
          lines                 = tb_pdf
        EXCEPTIONS
          err_max_linewidth     = 0
          err_format            = 1
          err_conv_not_possible = 2
          OTHERS                = 3.

Maybe you are looking for

  • Macbook Pro Help Please! Why does it randomly shut off?

    My late 2009 Macbook OSX 10.9.2 keeps on randomly shutting down. When it's charging, everything works fine. However, if not, the computer randomly shuts off either 2 min into when I use it or 20 min into it. Below I have included the power report and

  • Optical drive not recognized

    Ok - I'm trying to work out what the heck has gone wrong with my optical drive. I think it started from when i updated from 10.5.8 to 10.9. I had been having trouble reading any disks at all and sat down to try and fix it, when I looked more into it

  • Load CSV file into a table when a button is clicked by the user

    Hello, Can anyone please help me out with this issue, I have a form where in a user comes and uploads a CSV file and clicks a button, when the button is clicked - it should load the CSV file data into the database table for the corresponding columns.

  • Logo outline transparent for web

    I have created a logo. I did it with black fill and white lines. This works well for a white background, like in print; but for the web the white needs to be transparent so the background colors show through and where lines cross you can see the back

  • Just A Question On 7D

    Hey there Premier users/enthusiasts,      I'm new here, and would just like to ask if the Adobe Premier CS5 have a conversion system for the 1920x1080 7D raw files, just as Final Cut Pro HD has 'apple ProRes 422.' Would Appreciate all comments at sug