Can someone do it for me please I am totally lost :(

Write a simple application class with only a main method. It should convert the single command line argument into an integer and print the result. When converting the integer, catch any exceptions that might be thrown and print the exception object caught along with the
stack trace. >java NumberConvert
java.lang.ArrayIndexOutOfBoundsException: 0
at NumberConvert.main(NumberConvert.java:15)
java NumberConvert abc java.lang.NumberFormatException: For input string: "abc"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48 )
at java.lang.Integer.parseInt(Integer.java:426)
at java.lang.Integer.parseInt(Integer.java:476)
at NumberConvert.main(NumberConvert.java:15)
java NumberConvert 99 Your argument was 99
Write a class called "Temp" that stores a temperature. Write four methods for accessing the object, one called Celsius() that returns the temperature in degrees Celsius, one called Fahrenheit() that returns the temperature in degrees Fahrenheit, one called Rankine() that returns the temperature in degrees Rankine, and one called Kelvin() that returns the temperature in degrees Kelvin. Also write four accessing methods to set the temperature (setCelsius(), setKelvin(), setFahrenheit() and setRankine()) using any temperature scale. These methods should throw an unchecked exception (RuntimeException) if a temperature argument is supplied that is below absolute zero (273.15�C). The relationship between temperatures are F=1.8*C+32, K=C+273.15, R=F+459.67. Use the following main() method in your class as a unit test.
public static void main (String[] args)
Temp t = new Temp();
t.setCelsius(Double.parseDouble(args[0]));
System.out.println("Celsius: " + t.Celsius());
System.out.println("Kelvin: " + t.Kelvin());
System.out.println("Fahrenheit: " + t.Fahrenheit());
System.out.println("Rankine: " + t.Rankine());
java Temp 100 Celsius: 100
Kelvin: 373.15
Fahrenheit: 212
Rankine: 671.67
java Temp -300 Exception in thread "main" java.lang.RuntimeException: Temperature below absoute zero!
at Temp.setCelsius(Temp.java:18 )
at Temp.main(Temp.java:30)
Modify the solution from the previous problem so that the main method also catches the exception thrown by the accessing methods, prints a message and then exits gracefully. Also modify the temperature class so that the exception thrown on error is a checked exception (Exception). Also specifically check for the ArrayIndexOutOfBoundsException that might be thrown if the user does not supply a command line argument and the NumberFormatException that might be thrown if the argument is not a number and supply appropriate diagnostic messages.
java Temp 100 Celsius: 100
Kelvin: 373.15
Fahrenheit: 212
Rankine: 671.67
java Temp You must supply the temperature on the command line.
java Temp abc Your command line argument could not be formatted as a number.
java Temp -300 Temperature is too low. Must be above -273C.
Modify the solution from the previous problem so that the temperature class throws a checked exception derived from Exception called TempTooLowException. This exception should have a constructor that takes the temperature value that was attempted to be used as a string (with the temperature scale abbreviation included) and then composes a message like "-300C is below absolute zero!". Make sure that the main method checks for this exception and then displays the message to the user if this error occurs (do not just print the exception object, only print the internal message). Main should still catch Exception as a last resort and simply print out the object thrown before exiting.
java Temp 100 Celsius: 100
Kelvin: 373.15
Fahrenheit: 212
Rankine: 671.67
java Temp You must supply the temperature on the command line.
java Temp abc Your command line argument could not be formatted as a number.
java Temp -300 -300.0C is below absolute zero!

How come you don't know how to do this? Wasn't there a textbook which came with the course? Lectures? Did you ask your teacher?
If you have no idea where to start, you cannot be helped here, I'm afraid.
Try this:
http://java.sun.com/docs/books/tutorial/getStarted/index.html
and then:
http://java.sun.com/docs/books/tutorial/java/index.html

Similar Messages

  • I've downloaded the free pixel bender plugin for my mac (it says toolkit) for cs5 but I don't know how to put it in my filter list, can someone walk me thru it please?

    I've downloaded the free pixel bender plugin for my mac (it says toolkit) for cs5 but I don't know how to put it in my filter list, can someone walk me thru it please?

    Copy it in the respective plug-in folder.
    Mylenium

  • HT5429 direction is not coming in IOS 6 in india. can someone help me for the same?

    direction is not coming in IOS 6 in india. can someone help me for the same? i'm using iphone 4

    Hi Civilclerk1,
    In order to achieve your requirement, we can try to use the following expression to instead the last_name column and first_name field:
    last_name: =iif(Fields! staff_role.Value="Lead Atty" or Fields! staff_role.Value="BK Mgr" or Fields! staff_role.Value="Partner" ,Fields! last_name.Value,nothing)
    first_name: =iif(Fields! staff_role.Value="Lead Atty" or Fields! staff_role.Value="BK Mgr" or Fields! staff_role.Value="Partner" ,Fields! first_name.Value,nothing)
    Besides, if we don’t want see the blank row in the tablix, we can add a filter as below in the tablix:
    Expression:=iif(Fields! staff_role.Value="Lead Atty" or Fields! staff_role.Value="BK Mgr" or Fields! staff_role.Value="Partner" ,1,0)
    Operator:=
    Value:=1
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Crackling loudspeaker? Can someone test this for me?

    I've noticed something that might be abnormal about the speakers on my iPhone 4S.
    Could someone test this for me please? Go to ringtones, and play the 'bell tower' ringtone making sure your ringer volume is all the way up. Listen closly to the speaker, can you notice a slight crackling sound at parts?
    Thanks

    So when you play the bell tower tone at full volume it sounds perfectly cripst and doesn't 'crackle' or distort a little bit because mine does.
    Also when I've asked siri a question, the tone after that when it plays sounds like it distorts a bit to.
    Cheers

  • Cracking Loudspeaker? Can someone test this for me

    I've noticed something that might be abnormal about the speakers on my iPhone 4S.
    Could someone test this for me please? Go to ringtones, and play the 'bell tower' ringtone making sure your ringer volume is all the way up. Listen closly to the speaker, can you notice a slight crackling sound at parts?
    Thanks

    So when you play the bell tower tone at full volume it sounds perfectly cripst and doesn't 'crackle' or distort a little bit because mine does.
    Also when I've asked siri a question, the tone after that when it plays sounds like it distorts a bit to.
    Cheers

  • Hey Community, i have an iphone 5 recently doesnt work, it's showing apple in middle even i connect to itunes there is nothing. Can someone tells me the problem please thank you

    Hey Community, i have an iphone 5 recently doesnt work, it's showing apple in middle even i connect to itunes there is nothing. Can someone tells me the problem please thank you

    you could try forcing it into recovery mode by turning it off, hold the home button and plug it into iTunes at the same time, keep holding the home button until iTunes says its detected a device that needs to be updated or restored. Then restore.

  • HT1937 Hi few days ago I bought a second hand iphone 5 white 64 gb, and when I try to activate it I see the following message: "This iPhone can not be activated for service.please contact your carrier or AppleCare"

    Hi few days ago I bought a second hand iphone 5 white 64 gb, and when I try to activate it I see the following message: "This iPhone can not be activated for service.please contact your carrier or AppleCare"

    So then do what it says...contact Apple or your wireless carrier.
    However your phone is probably locked to another carrier and cannot be used on yours.

  • I am not able to download any  app on my ipad mini , it shows its loading, but never getting downloaded , can someone fix this for me ???

    i have a ipad mini , ios version 8.3 .... i am not able to download any app currently on my ipad.... i am not able to figure out the problem , it shows the app is loading in app store , but its never getting downloaded....how do i fix this problem ??? can someone please figure it out ???

    Welcome to the Apple Community.
    When your account becomes disabled, Apple provides the following recommendation:
    "This message means that someone tried and failed to sign in to your account multiple times. The Apple ID system disables the account to prevent unauthorized people from gaining access to your information. You need to reset your password, following the instructions at the Apple ID website".
    Visit iForgot.com and follow the instructions there.
    In order to change your Apple ID or password for your iCloud account on your iOS device, you need to delete the account from your iOS device first, then add it back using your updated details. (Settings > iCloud, scroll down and hit "Delete Account")
    Providing you are simply updating your existing details and not changing to another account, when you delete your account, all the data that is synced with iCloud will also be deleted from the device (but not from iCloud), but will be synced back to your device when you login again.
    In order to change your Apple ID or password for your iCloud account on your computer, you need to sign out of the account from your computer first, then sign back in using your updated details. (System Preferences > iCloud, click the sign out button)
    In order to change your Apple ID or password for your iTunes account on your iOS device, you need to sign out from your iOS device first, then sign back in using your updated details. (Settings > store, scroll down and tap your ID)
    If that doesn't help you might try contacting Apple through iTunes Store Support

  • Can someone compare these to imac please?

    Im looking to buy a used Imac. Can someone please compare the two imacs for me please? Which one is better? Would be using it for music (Pro Tools)
    For the 1st one here is the info I got for it.
    Model number-MC511XX/A
    S/N- W8*******5PE
    whats a fair price for this and is it worth it to buy.
    For the 2nd one here is the info I have.
    Model Number- A1311 im not sure if thats right based of how many charaters
    he also gave me this number 309lla
    <Personal Information Edited by Host>

    Introduced     July 2010
    Discontinued     May 2011
    Model Identifier     iMac11,3
    Model Number     A1312
    EMC     2390
    Order Number     MC510LL/A (3.2 GHz), MC511LL/A (2.8 GHz), MC784LL/A (2.93 GHz)
    Introduced     May 2011
    Discontinued     October 2012
    Model Identifier     iMac12,1
    Model Number     A1311
    EMC     2428
    Order Number     MC309LL/A (2.5 GHz), MC812LL/A (2.7 GHz)

  • Mac mini and LG monitor: screen is stretched and resolution is awful. Can someone help me fix this please?

    I have a Mac mini (bought in 2013) and the LG 20EN33 screen. I tried filing with the monitor's settings as well as the ones in display but the screen is stretched and the font is quite big. I saw a thread about Switch Res X so downloaded the app, but have no idea where to start to use it to correct issue. can someone help me please?

    You monitor is
    1600 x 900
    and only have VGA input
    http://www.lg.com/africa_en/monitors/lg-20EN33/technical-specifications
    With Switch-X you want to change the resolution to match your monitor's resolution.
    You have an old monitor and it may be best to get a new one that support the the now standard 1080p (1920X1080) resolution.
    I have not ideal how Switch-X works since I use the free version of Display Menu fro the Mac App Store

  • Can someone confirm this for me?

    Can someone try running ISOBuster 1.1?  (http://www.isobuster.com)  Without a BSOD of NO_MORE_IRP_STACK_LOCATIONS?
    How about Windows Component Update?  Without a BSOD of the same error?
    It seems this stupid BSOD plagues me and keeps me from installing Visual Studio.  
    I've tried the Registry Tweak and it still happens.
    I've tried different BIOS's with clean installs.
    I've tried different drivers with those different BIOS's with clean installs.
    I'm stumped and sad...

    Have you recently installed a new virus scanner?
    Winntmag has this to say : http://www.winntmag.com/Articles/Index.cfm?ArticleID=3396
    NO_MORE_IRP_STACK_LOCATIONS 0x35
    With this code, if you've added a new virus scanner or someone has accessed a shared volume over the network for the first time on the machine, the Server device driver can be at fault. The Server device driver constructs I/O request packets with a slot for every device driver on the path to the disk. Sometimes the number of I/O request packets the Server device driver allocates is insufficient, resulting in this Stop Code. Try increasing the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ServicesLanmanServer\IrpStackSize setting to a number higher than 4 (or whatever it's set to) and see whether the problem goes away

  • Can someone tell me for sure if the Nike  footpod works with the new 7th gen nano?

    I know that the nano can work by affixing to your hip and using the inbuilt sensor. I also realize that is not as accurate.
    I am wanting to specifically know does the new iPod nano sync with the Nike + footpod sensor - and recieve data from that. I've seen a couple of reports that it doesnt. I've seen a couple of reports that it does. The manual is useless. The reviews that says it does, says the sensor is now built into the ipod nano to recieve the data from the footpod wirelessly.
    Thanks for someone telling me for sure one way or another. I want to get one to run with, but I want to use the footpod and heartrate sensor.

    Yes it does. This is from the user manual:
    http://manuals.info.apple.com/en_US/ipod_nano_user_guide.pdf
    I found this on page 54.
    You can also use iPod nano with a Nike+ sensor or a Bluetooth heart rate monitor. Set up Bluetooth fitness devices in Fitness (see Setting Fitness preferences on page 34).

  • Can Someone Answer This For Me?!?!

    i got the kin one 3 days ago...i dont really like it that much because i cant view videos or download apps or really do anything that a smartphone should do and it is costing my parents $30 dollars extra a month for nothing basically. My question is that can i take the phone back and exchange it for a new one? Isn't there like a 30 day exchange or something with Verizon? I need to know this soon thank you for taking the time and reading this and answering it.

    You have 30 days to return the phone, and your account will return to the status it was before you upgraded.  Or you can exchange the phone for another - but you are only allowed one exchange, so make sure the second one is the one you really want,as that's the one you will keep.

  • Could someone tell me where I can download Office 2003 for Mac please?

    I need Word 2003 Mac version for work, I tried to find it on MS Office website but failed, where have they stored all the old versions?

    Word 2003 is a Windows-only product. If you want a Mac version of Word or Office, you need to find and purchase it.
    (58206)

  • Can someone help "THIS NU-B" please!!!

    Hey everyone,
         After putting of task of getting a new phone (my BB8330) I finally got it and have been tinkering with it.  And ran into several issues. . . . but this is the most important one so far!  Here goes:  Never owning such a cool phone as I do now, it wasn't hard to navigate the phone and its options and capabilities.  However, there were several media files that I quickly learned how to hide as an option under its properties tab, and in doing so, when I went back to un-click these media files, it would show up in the new media folder I created, but does not show the media? 
         I've made several attempts and at trying to re-open these files but was unsuccessful at doing so, and the message that kept prompting on my device reads as follows:
         Unable to display file/Media Card/Blackberry/pictures/XBBxMX/throbbin 3.rem
         I am at my wits end, and took the time to familiarize myself with this forum browsing through to see if anyone else had this similar problem and again, UNSUCCESSFUL!  So, I had these origional files sent from another blackberry user, saved these files in the pictures section of my phone's media card memory, clicked hide under each one's properties option, was able to un-click hide to show the media, but not able to view it!  
         Please please please, I hope some one can help me.........
    Advanced ALOHA and Much MAHALOs to those who can help me resolve this problem.
    hoping to hear from you soon,
    JSFM007

    Greetings, and welcome to the BlackBerry.com Support Forums.
    It is always helpful to receive help, to include your carrier name, so that when you have a question, that information won't need to be asked up front. Also, stating your device Operating System version is normally another common question, found on your BlackBerry at Options > About, third line down, looks like "v4.x.x.xxx"
    Likewise, you posted in the Welcomes and Introduction, not the place for asking questions.
    Nevertheless...
    JSFM007 wrote:
         Unable to display file/Media Card/Blackberry/pictures/XBBxMX/throbbin 3.rem
    You have your Media Card set to encrypt your media card. Open Options > Security >  Encryption > and see the setting for Media Card. This setting could be at Options > Security > General Settings according to the operating system of your device.
    JSFM007 wrote:
    So, I had these origional files sent from another blackberry user, saved these files in the pictures section of my phone's media card memory, clicked hide under each one's properties option, was able to un-click hide to show the media, but not able to view it! 
    That is where the 'rem' extension is coming from. Now, if that ecrypted file is sent from another device, it is ONLY viewable ON the device on which the encryption is set. You can't move the files to another BlackBerry and view them. That's the point of the encryption.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

Maybe you are looking for