System.read.in(); -problems when inputting numbers

Very wet behind the ears when it comes to java and having problems in inputting numbers. My course requires me to write a program that converts degrees c to degrees f. An addition is to have the user input the value of degrees c. When I input a value, say 0, then instead of c being that value it is 49 instead (maybe ASCII?). I sense that the problem is the System.in.read(); bit. I've preceded it with (int) and also tried (char) but to no avail. The other problem is how to get the program to accept a double figure or treble figure input (i.e 20 degrees c). My program is below. Any advice would be greatly appreciated.
//This program is designed to convert degrees Celsius into degrees Fahrenheit
class Ctof
     public static void main(String[]args)
     throws java.io.IOException
          //identify variables
          int c;
          double f; //double is needed as calculation involves fractions
          System.out.println("Please input a value of degrees Celsius then press [Enter]");
          c=(int)System.in.read();
          f=(c/(5.0/9.0))+32;
          System.out.println(c + " degrees Celsius"); //prints value of c
          System.out.println("This is " + f + " degrees Fahrenheit"); //prints value of f
}

I think this should work...
import java.io.*;
class Ctof
static BufferedReader b;
public static void main(String[]args)
throws java.io.IOException
//identify variables
int c;
double f; //double is needed as calculation involves fractions
b = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please input a value of degrees Celsius then press [Enter]");
c = Integer.parseInt(b.readLine());
f=(c/(5.0/9.0))+32;
System.out.println(c + " degrees Celsius"); //prints value of c
System.out.println("This is " + f + " degrees Fahrenheit"); //prints value of f
} I've added a BufferedReader to read data from the input stream (System.in). This then gets converted to an int. System.in.read() is only really for reading bytes.
Andrew

Similar Messages

  • Please read my problem when I configure Weblogic https

    I want to use https protocol and SSL for my web application in Weblogic
    I have a problem but I am not sure it's related to configuring Weblogic or not please if you can advice me
    I use "openssl" to be my own Certificate Authority (CA)
    I used this instructions for using openssl [http://www.g-loaded.eu/2005/11/10/be-your-own-ca/]
    after configuring openssl I used these steps for creating my keystore
    1. First I use this keytool for creating my private key and public key
    keytool -genkeypair -keyalg rsa -keystore ali_keytool.jks -storepass ali120 -alias ali_alias
    What is your first and last name?
         [Unknown]: AliKhosravi
    What is the name of your organizational unit?
    [Unknown]: Boors
    What is the name of your organization?
    [Unknown]: software
    What is the name of your City or Locality?
    [Unknown]: Tehranali_keytool.jks
    What is the name of your State or Province?
    [Unknown]: Tehran_Province
    What is the two-letter country code for this unit?
    [Unknown]: IR
    Is CN=AliKhosravi, OU=Boors, O=software, L=Tehran, ST=Tehran_Province, C=IR correct?
    [no]: y
    2. I create my CSR by this command
    keytool -certreq -alias ali_alias -keystore ali_keytool.jks -storepass ali120 -file ali_keytool.csr
    3. I sign the ali_keytool.csr by openssl . I do it like this :
    openssl x509 -req -in ali_keytool.csr -CA certs/myca.crt -CAkey private/myca.key -out ali_keytool.crt -days 365 -CAcreateserial -CAserial my_ca.seq
    4.Now my I have a signed certificate (ali_keytool.crt) and my CA certificate (myca.crt)
    and I import CA certificate to my keystore
    keytool -import -alias Openssl_ca -file myca.crt -keystore ali_keytool.jks -storepass ali120
    5. I import the signed certificate into my keystore by alias of private key
    keytool -import -alias ali_alias -file ali_keytool.crt -keystore ali_keytool.jks -storepass ali120
    6. I import the CA certificate again into a new keystore for creating Trust
    keytool -import -alias my_ca -file myca.crt -keystore ali_keytool_trust.jks -storepass ali120
    All steps done without any errors
    I used this address for help [http://www.startux.de/java/44-dealing-with-java-keystores]
    Now I want to configure kestores ans ssl in Weblogic
    7. I go to the Environment-->Servers-->AdminServer-->Keystore tab in wblogic
    8. I set "Keystores=Custom Identity and Custom Trust", "Custom Identity Keystore = H:\trust\ali_keytool.jks" , "Custom Identity Keystore Type=jks" ,
    "Custom Identity Keystore Passphrase:ali120"
    "Confirm Custom Identity Keystore Passphrase=ali120"
    "Custom Trust Keystore=H:\trust\ali_keytool_trust.jks" , "Custom Trust Keystore Type=jks" ,
    "Custom Trust Keystore Passphrase=ali120" , "Confirm Custom Trust Keystore Passphrase=ali120"
    9. Then I go to SSL tab and I set "Identity and Trust Locations=Keystores" , "Private Key Alias=ali_alias" ,"Private Key Passphrase=ali120",
    "Confirm Private Key Passphrase=ali120"
    10. I go to the General tab and select "SSL Listen Port Enabled"
    11. I user Firefox as WebBrowser so I configure my Browser I select Tools-->Options-->ViewCertificates --> Authorities tab
    and I import the server certificate here is "myca.crt the openssl certificate"
    in Downloading Certificate window I select
    "Trust this CA to identify web sites"
    "Trust this CA to identify email users"
    "Trust this CA to identify software developers"
    12. I restart Weblogic
    13. I try to loging in weblogic like this "https://127.0.0.1:7002/console"
    The webBroser show me this warning:
    This Connection is Untrusted
    You have asked Firefox to connect
    securely to 127.0.0.1:7002, but we can't confirm that your connection is secure.
    Normally, when you try to connect securely,
    sites will present trusted identification to prove that you are
    going to the right place. However, this site's identity can't be verified.
    What Should I Do?
    If you usually connect to
    this site without problems, this error could mean that someone is
    trying to impersonate the site, and you shouldn't continue.
    Technical Details
    I Understand the Risks
    I don't know why the WebBrowser show me this warning while I imported the Server Certificate
    I don't know that my problem is in configuring WebLogic or FireFox WebBrowser or Keystore
    If you know please advice me
    Thanks

    Moderator Action:
    You already aked this question a couple of weeks earlier:
    My problem when I enable SSL in Weblogic and I don't have a trusted CA cert
    This is a user-to-user forum.
    There is no obligation that anyone respond. They will answer if they choose to.
    If there is a business need for a resolution, use your service contract privileges and open a support ticket with Oracle Support.
    http://www.oracle.com/us/support/contact-068555.html
    This duplicate forum post is locked.

  • Page problem when saving numbers as to PDF

    I know how to print numbers to PDF file, but I want move some content to the next page, because they're a whole unit and I can'g separate them, but it seems numbers can't break a page manually, is there any one know a solution? thanks in advance.

    Hi summerdove,
    summerdove wrote:
    I know how to print numbers to PDF file, but I want move some content to the next page, because they're a whole unit and I can'g separate them, but it seems numbers can't break a page manually, is there any one know a solution? thanks in advance.
    There has never been "insert Page Break" in Numbers. Layout In Numbers 3 is even more clunky.
    Are those those objects grouped?
    To arrange objects on a page, the Alignment Guides will help:
    Numbers > Preferences > Rulers > Alignment Guides. Tick every box. The Guides do not print.
    Menu > View > Show Rulers.
    See this (clunky) User Tip on creating a Layout Guide in Numbers 3:
    https://discussions.apple.com/docs/DOC-7101
    Regards,
    Ian.

  • Adobe reader download problem on mac.  when i try to download reader it says i need adobe air.  when i try to download adobe air it says it's no longer available or supported.  i deleted the old air because i got a message saying i needed to delete it.

    adobe reader download problem on mac.  when i try to download reader it says i need adobe air.  when i try to download adobe air it says it's no longer available or supported.  i deleted the old air because i got a message saying i needed to delete it. what should i do?  my operating system is Mac 10.7.5

    You don't need Adobe AIR to download or install Adobe Reader.
    Try downloading the offline installer from http://get.adobe.com/reader/enterprise/

  • Display problem when reading Traditional Chinese in Crystal Report 2008

    Hi All,
    I have tried to connect MS SQL 6.5 to build up a report. However, I encounter a problem when read Traditional Chinese. all chinese characters turn into adnormal characters. I wonder it is problem of SQL Server or some setting that I may not know. In addition, I can able to read chinese in the application program , ISQL / Query Analyzer. Please help to give idea and suggestion to fix this. Thanks
    SQL Server: MS SQL Server  6.5
    Client OS: Window XP ( Traditional Chinese Version)
    Server OS: Window NT and Window Server 2000
    Stsyou

    Hi
    If you are using a Chinese language build database, Crystal Reports English build might not display the characters properly as non english databases include one byte characters as ASCII code character and double-byte characters as their own language code character.
    Traditional Chinese, Simplified Chinese, Japanese (Kanji, Hiranga, and Katakana), Korean and Vietnamese use double-byte characters.
    However, a possible workaround to this issue is to verify that the encoding on the database client is configured according to the examples below. Also, you will need to install the language pack in the English environment.
    CONFIGURATION EXAMPLES:
    Shift-JIS for a Japanese database
    Big5 for a Traditional Chinese database
    GB2312 for a Simplified Chinese database
    iso-2022-kr for a Korean database
    Windows 1258 for a Vietnamese database
    EXAMPLE SCENARIO:
    An Oracle database saves non-English language data such as Japanese.
    The Windows operating system is English.
    STEP TO CONFIGURE THE CHARACTER CODE IN THE ENVIRONMENT SETTING
    (This step is based on the details of the EXAMPLE SCENARIO.)
    1. Configure the system environment on the database client side to 'Shift-JIS' as the character code set in the Environment Setting.
    This results in the NLS_LANG variable set to Japanese_Japan.JA16SJIS under the registry HKEY_Local_Machine\Software\Oracle\Homeo.
    STEPS TO INSTALL LANGUAGE PACK IN AN ENGLISH ENVIRONMENT
    (These steps are based on the details of the EXAMPLE SCENARIO.)
    1. Add languages to the computer system by clicking:
    Control Panel > Regional Options > General
    2. Select the check box for 'Traditional Chinese', 'Simplified Chinese', 'Japanese', 'Korean' or 'Vietnamese'.
    3. Click 'Apply'.
    4. When you are prompted, insert the Windows CD-ROM to install the language pack.
    5. Restart the computer.
    Upon completing these steps, you are able to display the languages characters in the Crystal Reports Designer in a Windows English environment.
    ==========
    NOTE:
    If the database table and field names use non-English language characters, Data Explorer in CR will not correctly display these names. However, when you preview the report, the non-English data displays correctly.
    ==========
    Configuring the database client according to the examples and installing the language pack will display the characters successfully. However, there are cases when this workaround does not resolve the issue.
    For further information about CR and double-byte languages, refer to knowledge base articles, c2008083 and c2008349.
    Hope this helps!!!
    Regards
    Sourashree

  • Performance problem when using CAPS LOCK piano input

    Dear reader,
    I'm very new to Logic and am running into a performance problem when using the CAPS LOCK-piano-keyboard for input of an instrument: when I'm not recording everything is fine and the program instantly responds on my keystrokes, but as soon as I go into record-mode there is sometimes a delay in the response-time (so I press a key and it takes up to half a second longer before the note is actually played).
    Is there anything to do about this to improve performance (for example turning of certain features of the application), or should I never use the CAPS LOCK keyboard anyway and go straight for an external MIDI-keyboard?
    Thanks and regards,
    Tim Metz

    Does your project have Audio tracks and just how heavy it is, how many tracks? Also, what kind of Software Instrument do you use?

  • Problem when transporting form from DEV system to PRODUCTION system

    Hi Experts,
    We are developing forms in ABAP, for example there is a form developed in dev system and this form has JS coding in some UI elements events like initialize, on change and on exit; also has one script object defined as variable. this script object has some functions defined in order to do some common validations and field specific ones too.
    The form in DEV work fine, all the functions calling, all the validations and the events are working properly as expected. But there is a problem when we moved the changes done in development system into production system. Specifically the script object has the problem: even though the coding is the same in both systems, in production system we had an script error: "Body.CATALOGPARAMS has no properties", as if the Body.CATALOGPARAMS was never instanciated, or it is not defined...
    The code that produces this error is the following:
    var itemCount = 0;
    itemCount = Body.CATALOGPARAMS.DATA.instanceManager.count;
    CATALOGPARAMS is table defined as context table coming from an ABAP FM where is filled and passed into the form.
    In order to fix this problem I changed that part for the following
    var itemCount = 0;
    var catalogTable = null;
    catalogTable = xfa.resolveNode("Body.CATALOGPARAMS.DATA");
    itemCount = catalogTable.instanceManager.count;
    This still works as fine as the other in DEV system. But my question is: will I have the same problem when we transport the changes to production system, you have to know that a transport is not something that you can do every day, so I am taking precautions before the transport. Which of both coding is the best for doing this?
    Any observations, comments, questions in order to clarify some points are welcome, so please do it.
    In advance, thanks a lot.
    Mauricio.-
    Edited by: Mauricio Poblete on May 11, 2010 4:20 PM

    As always, you are the first one to reply... thanks for that!
    before everything, I activated the form, then I added this form to a new transport using se80 transaction: I navigated through the form objects and I added the form to a new transport by second click on the form -> other functions -> write transport entry. is this the correct way to assign a transport package with the entire form (including script objects, layouts, and all you told in the last reply)??
    Can you give me a guide on how-to add the specific parts to the same transport for forms?
    as always, thanks in advance.
    Mauricio.-

  • I'm having problems with FlashPlayerPlugin and plugin-container. They keep starting up and bogging down the system. This has been a recent occurrance. I've made sure that I have the latest version. I notice the problem when I am opening some applicatio, a

    I'm having problems with FlashPlayerPlugin and plugin-container. They keep starting up and bogging down the system. This has been a recent occurrance. I've made sure that I have the latest version. I notice the problem when I am opening some applicatio, and it freezes. If I go to Task Manager, I can see the two Adobe apps sucking up CPU cycles. If I end the processes, then the other apps continue. Today, I uninstalled FlashPlayerPluginqand plugin-container. All day since I have had no freezing of an app. What should I do to correct the problem?

    Here's an explanation of what those processes are. 
    Inside Flash Player Protected Mode for Firefox
    I'm curious about what you did to uninstall just those.

  • I use LabVIEW 7.1 but I have some problem when, I use LabVEW to read the data from serial communication

    I use LabVIEW 7.1 but I have some problem when, I use LabVEW to read the data from serial communication.
    I use LabVIEW to read the data from serial communication then, i open the example (.vi) from Serial Communication - Advanced Serial Write and Read  from LabVIEW Example. BUT it have some error message that : Error - 1073807202 occured  at property node in visa configure serial port (instr).vi -> advance serial write and read .vi
    this error code is undefined. no one has provide a description for this code, or you might have wired a number that is not an error code to the error code input.
    I don't know why? please help me. thank you.

    When I copy that code into "Explain Error" I get: "VISA:  (Hex 0xBFFF009E) A code library required by VISA could not be located or loaded."
    You may have a bad install of VISA or the wrong version of VISA loaded. Try re-installing VISA. You can get the latest version from the NI support site: http://digital.ni.com/softlib.nsf/webcategories/85256410006C055586256BBB002C0E91?opendocument&node=1....
    Also ensure that you are not pointing the example towards a serial port that does not exist.
    Please let us know what you find and what gets this working for you.
         Rob

  • Problems when reading some CDs

    Sometimes my MBP fails to read CDs correctly. I insert a disk, and it spins up as expected. Sometimes the disk will mount and I can view the contents of the disk, sometimes it doesn't even get that far.
    What happens is that the drive sounds like it's spinning up for a couple of seconds, and then it slows again for a couple of seconds. This repeats continuously and the system becomes very sluggish when this occurs. If the disk managed to mount, it is possible to get it to eject, but the system responds very slowly. If the disk didn't mount I have to reboot and hold the mouse button to force it to eject.
    This doesn't happen with all CDs. It's happened on a couple of audio CDs, and on one data CD. Trying the disks again later they work fine. When using an external DVD drive I have no problems at all. It appears to be quite random regarding which disks work and which don't.
    Any light that can be shed on this problem would be greatly appreciated. This is my first Mac and (apart from this issue) I am very impressed with it so far!
    Thanks,
    Guy.
    Oh, and my MBP is fully up-to-date with 10.4.7, firmware updates etc.

    This seems like the same problem.
    http://discussions.apple.com/thread.jspa?messageID=2703037
    User, Uteaholicslc , stated the following:
    "Just an FYI, I called customer service and told them of my problem and they said that these forums are sent to the software engineers so they've been aware of this problem for some time now. She said that they would have a firmware update that should fix the problem within a month or so. Maybe she was just telling me what I wanted to hear. I guess only time will tell."
    Im wating on word from the company. I have time under the warranty to fix it if I had to send it back but it wont be till christmas. Oh well hopefully it is just firmware.

  • Hi All, I have question about the iMac operating system. I have the last updated. The problem when I manage the place of the folder windows they are all mixing up. I mean they not on the place where I left them. how to set they stay on the same place. Tks

    Hi All, I have question about the iMac operating system. I have the last updated. The problem when I manage the place of the folder windows they are all mixing up. I mean they not on the place where I left them. how to set they stay on the same place? I know there are different possibilities to set.
    I tried but it not helped for me. What I can do? How and where can set this they stay on their place?
    Thanks.
    laci

    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Repair Database. If that doesn't help, then try again, this time using Rebuild Database.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. (In Library Manager it's the FIle -> Rebuild command)
    This will create an entirely new library. It will then copy (or try to) your photos and all the associated metadata and versions to this new Library, and arrange it as close as it can to what you had in the damaged Library. It does this based on information it finds in the iPhoto sharing mechanism - but that means that things not shared won't be there, so no slideshows, books or calendars, for instance - but it should get all your events, albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. 
    Regards
    TD 

  • I bought a new MacBook Pro (Mac Os 10.8.4) when conecting my mobile broadband dongle (Huawei E122) the computer does not read it at all. I do not have problems when connecting it to my former computer (PC) and a Mac from last year. Any suggestions?

    I bought a new MacBook Pro (Mac Os 10.8.4) when conecting my mobile broadband dongle (Huawei E122) the computer does not read it at all. I do not have problems when connecting it to my former computer (PC) and a Mac from last year. Any suggestions?

    Thanks,
    Yes, I did that. They have uppgrades for the dongles, but just untill Mac Os 10.7. Their solution is to buy a new modem from them or getting one for free if I sign a contract for 24 months! So, i think from that side not very helpful.
    It is just that I do not want to buy a new modem, when it works in quite recent computers and after having spent money in the new Mac.
    But thank you for your reply!

  • A namespace problem when doing Create InfoArea in bw system

    Dear all,
    we met a problem when excute a process in our bw system:
    our process as follow:
    rsa1(Data Warehousing Workbench:Modeling) --> InfoProvider --> Create InfoArea
    then a error message window came out as below.
    error in object editing
    No valid change license available for n
    /BPR3R/
    Choose 'Display object' or 'Cancel'.
    its detail message is as follow:
    Message no. TO127
    Diagnosis
    You cannot edit the object AREA 0INDUSTRIES. This may be due to the following reasons:
    The corresponding namespace /BPR3R/ is not entered in the namespace table with a valid change license.
    In the namespace table there is no entry with a valid change license that matches the template /BPR3R/.
    System Response
    The function terminates.
    Procedure
    Check the name of the object AREA 0INDUSTRIES. If necessary, choose another object name.
    Otherwise, let the system administrator check the change licenses of the namespaces in your SAP system.
    Maintain the namespaces in the Tools of the Transport Organizer under Administration -> Display/Change Namespaces.
    You need to check and correct the entries that match the template /BPR3R/.
    You need to distinguish between the following cases:
    The namespace is /0SAP/:
    Make sure that the namespace role is C (recipient) and the flags SSCR popup and SAP standard are activated. The license fields remain empty.
    You did not create the namespace yourself. Instead, the namespace owner is SAP or another software vendor.
    Make sure that the namespace role is C (recipient). The field Repair license must either contain the valid license, or the flag SSCR popup must be activated. Contact the namespace owner and ask what you should now do, and what the valid repair license is.
    You are the namespace owner:
    Proceed according to the documentation on applying for and setting up namespaces. If the namespace role is P (producer) then you need a valid development license. For information on this, see the SAP Library under BC - Basis Components -> Change and Transport System -> BC - Namespaces and Naming Conventions -> Reservation of Namespaces).
    Then we did the below action:
    se06 --> system change option
    in this view, we found  /BPR3R/ this Prefix.
    And it is empty in  /BPR3R/ 's namespace/name range volume.
    What is next action we should take to solve this problem?
    Anyone experienced or expert,
    Please kindly give advice.
    Regards,
    Allen

    Hello Allen,
    Cold you please check the following notes which explain about this namespace creation and transport ?
    401778 - Using namespaces to develop individual BW objects
    150451 - Setting up development namespaces
    105132 - Reserving namespaces
    150451 - Setting up development namespaces
    Best regards,
    Rafa

  • Cannot email pdf using Acrobat Reader XI v11.0.3 in Windows 8. No problem when using in ms vista. ge

    Cannot email pdf using Acrobat Reader XI v11.0.3 in Windows 8. No problem when using in ms vista. get "authentication error". Sometimes will get a very quick dialogue box showing the gmail login screen but then disappears. I use firefox and IE

    Hi Rodney
    Welcome to Apple Discussions
    This sounds like one of those "oddities", contributed to by a few sources.
    I can clear the Safari cache files as a temporary solution, but I encounter the same difficulties with the “problematic” files once they have been opened again.
    Wondering if you disabled the Safari Cache would the refresh function work correctly? As a test you can disable the Safari Cache by Emptying the Cache first via the Safari menu, then Quit Safari. Now go to the Finder>Your User Library>Caches>Safari. Single click on the Safari folder, then Apple Key + I to open Info panel. There, check the "locked" box. This prevents further additions to the cache. The downside, you lose your ability to upload images etc. within Safari (my cache is disabled, so I use Firefox for the uploads).
    Then restart Safari. Try the PDF from within Safari.
    Post back

  • I have problems when using the camera on my iPhone 4S (the same for my daughter with a iPhone4) A veil around the blurred photo, a development impossible and completely unable to read the bar code or QR code. What to do?

    I have problems when using the camera on my iPhone 4S (the same for my daughter with a iPhone4)
    A veil around the blurred photo, a development impossible and completely unable to read the bar code or QR code. What to do?

    Sounds kind of stupid, but check to make sure that your iphone case cover is not blocking the edge of the camera lens.  I had a silicone case on my 3S and when it got older, it started tot slip and the edges of my pictures were blurred.

Maybe you are looking for

  • How to use case when function to calculate time ?

    Dear All, May i know how to use case when function to calculate the time ? for the example , if the First_EP_scan_time is 12.30,  then must minus 30 min.   CASE WHEN FIRSTSCAN.EP_SHIFT <> 'R1' AND FIRSTSCAN.EP_SHIFT <> 'R2' THEN ROUND(CAST((DATEDIFF(

  • Storage vendor model information

    Is there a way to get to the storage vendor model data in vHA? Sometimes my reports have this, sometimes it is blank? I can get to a view that will tell me it is "Hitachi" storage, but cannot get the array model number? Maybe I am not looking in the

  • Restriction SSID Per User with ACS 5.x version

    Hi I would like to ask some question on WLAN technology, which I using WiSM version 2. And i get requirement that user must be restrict with SSID, so, i found that it can do it on ACS version 4.x via NAR for SSID-based authentication feature. Then, i

  • Safari shuts down on Streaming Video (AVI or WMV)

    Any time I go to a site that have streaming video (other than YouTube), Safari and Foxfire will lock up and shut down. It seems to happen when the video being streamed is an AVI or WMV file. I didn't have this problem with earlier versions of Mac OS.

  • Tengo un problema con itunes, Tengo un problema con itunes

    En mi iphone aparece lo siguiente PARECE Que la Tarjeta SIM of this iPhone No Es compatible. La Tarjeta SIM Que Tiene instalada en this iPhone es de la ONU Operador no admitido según rubro la Politica de activation asignada ACTUALMENTE Por El Servido