Result comes out to Zero for program from Fahrenheit to Celsius!

Hello,
I have a minor glitch in my program. It comes out to zero for the result each time. Could anyone take a quick look to see what I"m overlooking. Any help would be greatly appreciated. Much Regards,
Here is the code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Temperature extends JFrame {
     private JPanel p;
     private JLabel label1;
     private JLabel label2;
     private JTextField F;
     private JTextField C;
     public Temperature() {
          label1 = new JLabel( "Enter temperature in degrees Fahrenheit: " );     
          label2 = new JLabel( "The temperature in degrees Celcius is: " );
          F = new JTextField (10);
          F.addActionListener(
          new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    int iF,iC ;
                    iF = Integer.parseInt( F.getText());
                    iC = (int) ((5/9) * (iF - 32));
                    C.setText(String.valueOf(iC));
               } // end actionPerformed()
          } // end ActionListener()
          C = new JTextField(10);
          C.setEditable(false);
          p = new JPanel();
          p.setLayout (new BorderLayout());
          p.add (label1, BorderLayout.NORTH);
          p.add (F, BorderLayout.CENTER);
          p.add (label2, BorderLayout.SOUTH);
          Container c = getContentPane();
          c.setLayout(new BorderLayout());
          c.add(label1, BorderLayout.NORTH);          
          c.add(p, BorderLayout.CENTER);
          c.add(C, BorderLayout.SOUTH);
          setSize(300,150);
          show();
     } // end Temperature()
     public static void main(String args[]) {
          Temperature app = new Temperature();          
          app.addWindowListener(
               new WindowAdapter() {
                    public void windowClosing(WindowEvent e)
                         System.exit(0);
     } // end main()
}// end class Temperature

Change your calculation line to...
iC = (int) ((5.0/9.0) * (iF - 32));
The problem was that (5/9) is an integer divided by an integer which gives an integer result (0).
Regards,
Tim

Similar Messages

  • IR 6570 fax TX report or "confirmation page" comes out with zeros.

    Our office has a Image Runner 6570. It works fine, except for our Fax TX Report or confirmation page comes out with no info. THe Job No./ St. Time/ Usage T/ Pages all come out as zeros. The fax goes through to the reciepent, but we would like the cofirmation page to work as intended. We turned off the IR 6570, that didn't affect anything. We switched the Fax TX report seetings from off to error and on, but it still comes out as all zeros. 
    If anyone has had this issue or knows how to resolve it, a comment would be apreciated. 

    Hi CalebR!
    Thanks for posting in the Canon Forum! Canon does not provide direct support for imageRUNNER series products, but your dealer will be able to help you! If you don't have a dealer, please call us at 1-800-OKCANON (652-2666) and we will be happy to provide dealers who are in your area.  

  • Hi is true that there will be a iphone 6 comming out in july if u could pls get back to me as I want to buy the iphone 5s but if the iphone 6 is comming out ill wait for that one

    Hi is it true that the will be a iphone 6 comming out in july if any one could tell me cos I want to get the iphone 5s but if there will be an iphone 6 comming out ill wait for that one if any one could let me know thanks

    This is a user to user help forum only so doubtful is anyone here knows. If someone here is priviledged to this info in advance, they are under Apple's strict non-disclosure agreement which prevents them from saying until Apple make an announcement.

  • When ios 7 comes out is it for all idevices and is it just an update

    When ios 7 comes out is it for all idevices and is it just an update

    The final version of iOS 7 will be a free update and compatible with a fifth generation iPod touch, iPhone 4, second generation iPad, iPad mini, and newer.
    (84447)

  • How do you change the weather from Fahrenheit to Celsius in iPhoto for iOS?

    I have been trying to change the weather from fahrenheit to celsius and I cannot seem to find out how. Can anyone help?

    I had the same thing happening after upgrading to IOS 7.
    I clicked on the weather notification which opened a new tab
    https://www.dropbox.com/s/sai5kn3xufrqngd/IMG_0013.PNG
    I just had to click on the °C to get the Celsius displayed both in the app and the notification.
    Maybe a reboot would help ?

  • Photo comes out black when I import from Iphoto to Imovie..

    Im trying to make a video from Imovie.
    but whenever I drag a photo from Iphoto to the project in Imovie, it comes out black when I play it..
    Does anyone has solution for this one??

    This is in the previous HD version of iMovie. I just tried it and they come in okay in the new iMovie.

  • Create Laucher for program from macports

    I am running mountain lion (10.8.4) on a MacPro.  I have downloaded the geany editor using macports ("sudo port install geany").  I can start the program from a terminal using the command "geany" or "geany file.py" if I wish to edit the file "file.py" (I program in python).  I am completely new to the Mac world (having come from Ubuntu Linux).  Note that geany uses XQuartz.  I wish to create a laucher app for geany and to make geany the default editor for .py files.  From what I have read applescript is the way to do this, but nothing I do works.  Any suggestions or links or references would be greatly appreciated.  I can write bash and python scripts to launch geany but cannot get beyound that point.  I keep coming across the comment that the applescript rules have changed for mountain lion.

    Use Applications -> Automator -> Application -> Run Shell Script
    Change the "Pass input"  to "as arguments"
    Change the
         echo $f
    to the full path to your geany executable.  Leave the $f
         /the/full/path/to/geany $f
    Save the Automator app. Give it a name you like.
    Now you can use twtwtw' trick to assocate .py files with the Automator app you have just created.

  • Has Apple come out with patch for iPhone-Bluetooth connection problem?

    I have a Mini Cooper with Bluetooth compatibility and it was compatible with my iPhone for a couple of months, but I have found out that it only syncs up with iPhone software versions of 2.0 or 2.0.1. It seems that when I downloaded tunes on my iPhone from iTunes, it automatically "upgraded" my software on my iPhone to 2.0.2, which now makes it imcompatible with my Mini's bluetooth. Has Apple come out with the patch for this problem yet? I can't believe I'm the only one with this problem. If Apple doesn't advertise the patch for this pretty soon, I'll be blogging for help on this throughout the Internet. I have called Apple....they have put me on eternal hold and still have not given me a positive answer on this dilemma. Apparently the "senior" software guys haven't gotten the word on this coming problem for them. Needless to say my frustration is to the point of chucking this attractive nuisance into the river and going back to a less sophisticated form of communication. Anyone have any information on this? Thanks in advance.

    You can send feedback to Apple regarding your issue with the Mini - http://apple.com/feedback . You could also contact Mini and see if they are working on a patch for their bluetooth.
    I haven't had the fuzzy picture issue except when my hand shakes while taking a picture. There will never be a perfect update where no one has a problem. If you wait for the perfect update, you'll never update any electronic device.

  • I have purchased a lot of music .games and movie but 2 of my movies saying error and when i come out of the coffee shop from wifi  most of my games wont play and i payed for this stuff

    i have downloaded a lots of games and movies and music the music part is fine .but two of my movies keep saying error and most of the games wont work with out  the internet and one is not competerble with my ipod i just wont   them off my ipod touch, and i dont wont to be charged for something that i cant use  and i can make room for some more things to put on my ipod touch so please help me i am desperet please  email me i am looking forward to for your help. please help thank u regina claiborne.

    It is your fault if you bought apps that are not compatible with your device or that require internet connection.
    The product description will tell you all of this.
    If there is an issue with the movies playing, then report the issue to itunes.  They will resolve within a day.
    How to report an issue with Your iTunes Store purchase

  • Can I send out a frequency for radio from my iMac..?

    So, hopefully I worded it right. What I am trying to do or if it can be done, is try sending out a radio frequency and tune my stereo to it and play what ever is playing on my mac on my stereo. I want to do this because I don't want a converter to go into my headphone jack then lose my iMac speakers. They are awesome! Anyway, thanks for helping in any way.
    I love your MAC

    I love your MAC wrote:
    i dont know.... If there is somehow to do it with the imac or any other mac, that would be awesome.
    Maybe you could try to write a program that used precisely the right amount of CPU cycles :-p
    But no, there's nothing built in. The USB dongle sounds like a good path to take

  • Everytime i try to update my apps it comes out asking me for my password but with another email that is not mine!! I sign out just in case and when i sign in again with my real ID and try to update and still it comes out with wrong email!!!HELP!!!

    Can someone help me!! I really need to update my apps! I sign in with my apple id and password but when i go to update it asks me again for my password but with an email i do not reconize!! can someone help!!

    A stranger's Apple ID appears on your Mac in conjunction with an update notice -
    https://discussions.apple.com/docs/DOC-5261

  • Why does amplitude come out as zero?

    Hi,
    I want to measure peak to peak of a square signal (0.1- 2Vac). I generate and aquire the signal using a USB-6008.
    I have tried to do this in various ways as you can see in the attachments, but all I get is zero. The signal is being read perfectly.
    Any idea what is wrong?
    Heidi
    Solved!
    Go to Solution.
    Attachments:
    Aquire.vi ‏118 KB
    Generate.vi ‏74 KB

    heididebwil wrote:
    I have tried to do this in various ways as you can see in the attachments,
    I only see one way, not various, in you attachment. Please explain.
    heididebwil wrote:
    ..., but all I get is zero. The signal is being read perfectly.
    How can it be zero (what you don't want) and read perfectly (what you want) at the same time. Please explain.
    (Sorry, I don't have DAQmx installed, so I cannot see your express configurations)
    Are you sure the device name is set correctly? How are you running this? Why are none of you error out terminals wired, e.g. even to an indicator.
    LabVIEW Champion . Do more with less code and in less time .

  • Will verizon come out with 4g for the iphone soon?

    my phone is so slow

    Yes, as the previous posters have said, 4G has been out for the iPhone since last year(September, I think).
    Unfortunately, just as with any other brand of phone, this does not mean that older versions of the phone will have 4G capability. You have to purchase the newer model to take advantage of the newer technology.

  • Mixdown Garage Band Track to iTunes - result comes out silent.

    I use garage band to contain several tracks I have recorded live. I mute and lock all tracks except the one I want to play I unmute and then choose mixdown to iTunes. The resulting file in iTunes is silent. When I go back and try to play the unmuted track in Garage Band it plays silent. Only when I double-click on the track and choose 'monitor sound' then go back to the track window does it then play in Garage Band and then I can send it to iTunes successfully. The problem is, I still haven't discovered why a track will not play or send to iTunes. What control is making this happen/not happen. Apparently the 'monitor sound' check box is not the answer because sometimes it works and sometimes not. There seems to be something else that is causing a track to be silent or to play and it is other than the mute button.
    Any clues on this?
    TIA,
    Ken

    I use garage band to contain several tracks I have
    recorded live. I mute and lock all tracks except the
    one I want to play I unmute and then choose mixdown
    to iTunes.
    There is no reason to lock a track you don't want to play. Locking is very useful if you have a lot of effects, or if it is a software track that is taxing the CPU. If none of those conditions exist, then locking is a wasted effort.
    The resulting file in iTunes is silent.
    When I go back and try to play the unmuted track in
    Garage Band it plays silent. Only when I double-click
    on the track and choose 'monitor sound' then go back
    to the track window does it then play in Garage Band
    and then I can send it to iTunes successfully.
    The monitor function should only be a factor when recording, not on playback. It is to allow you to monitor with any effects you have selected while recording. I never use this option, because I don't apply any effect until I have recorded the track and I am mixing.
    The problem is, I still haven't discovered why a track
    will not play or send to iTunes. What control is
    making this happen/not happen. Apparently the
    'monitor sound' check box is not the answer because
    sometimes it works and sometimes not. There seems to
    be something else that is causing a track to be
    silent or to play and it is other than the mute
    button.
    Any track that is muted will not play. If you have any tracks soloed, no non-soloed tracks will play. I am not sure just what you could be doing here. Make sure all tracks are not muted and not soloed. Then mute any you don't want, and mix to your satisfaction. When you are satisfied, export to iTunes should give you exactly what you hear in GB.

  • Will Apple come out with update for Siri to recognise Asian accent?

    Had a hard time using Siri as most of the time it cannot recognise the words that I said.
    And Siri doesn't allow search to be done outside US.
    This really make Siri not that attractive in Asian.

    Like what penguin said......If apple doesnt say it, I wouldnt believe it. I just read an article this morning SPECULATING Siri for the Ipad 2 around holiday time. Its those websites jobs to speculate which attracts readers(like me for example). I highly doubt it though.

Maybe you are looking for

  • Using a jscript file?

    hey, I am using a template that i purchased for my website. Within the folder there is a flash movie that shows all of the flash effects that the site is supposed to do, including the intro. I noticed a file inside of my "scripts" folder. It is a jsc

  • Reading the form as XML, using WDJ

    Hello. I'm using WD for Java and ZCI layout. I've seen this thread- Re: Data in dynamic table not pass to webdynpro java about getting data from tables in the form by reading the form's XML data. I tried to search for a method to get the XML in IWDIn

  • Many to many displayed in list

    I'm developing a file manager where files have titles, descriptions, and subject categories amongst other things. File -> Subjects is a many to many relationship, linked by a file_subject table. I have successfully used the Many to Many Wizard to mak

  • Configuration information

    Hi, We are going to use AT-MIO-16E-10 and PCI-DIO-32SH in RTX subsystem, a real-time extention for Windows NT. I need detail information about the port addresses for all analog and digital I/O for development of device drivers in RTX. Does anyone kno

  • How to open URL stored in recordset

    How can I make a URL in a displayed Recordset clickable in such a way that the stored URL (like: http://www.mysite.com) is opened?