How do you test if a string could be a valid int and then convert to int?

Hello, my name is Esran41 and I'm new to this site. I'm in computer science one this year and our current assignment is to make a console based Tic-Tac-Toe game. The final program must be able to detect errors in the user's input. For example, if the program asked the user for an int and he typed a character, our program must recognize this, print an error message, and then prompt him for the int again. I also need to know some common string manipulation methods(like String.length) and their syntax too. Again, I'm extremely new to java, so please include code fragments and example programs to demonstrate these methods.
To sum-it-up, I need to know how to do the following(The syntax):
Method (1)
- test an inputed string to see if it's a valid integer
- report an error to the user if it's not a valid integer
- if there was an error, prompt the user again
Method (2)
- Pass the inputed string as a parameter
- Convert the string into an integer
- return the integer
Also, what is a try-catch statement, what does it do, and how is it implemented?
Please post any advice or help that you may have pertaining to my problems.
Thanks!

Do not insult me. If I could read my computer science
book, I would. Please don't insult yourself... by pointing out your limitations...
I will apologize for my cynical remarks... You should see how many requests for " I need help" where the answer could be found so easily...
But it is quite obvious that you have access to the internet... If you did a search for Java, eventually you would find yourself as Sun's web site... Which means that you would have arrive at this page...
http://java.sun.com
and towards the bottom left had corner of that page you would find these links...
Learning
New to Java Center
- Tutorials & Code Camps
- Online Sessions & Courses
- Course Certification
- Instructor-Led Courses
- Quizzes
And you will find the same resources that I am using to learn Java...
I'm looking up this information not only for myself, but for my class too....
Thus, we are stuck with old computers, about twenty books for 220 kids, and one teacher who is great at >C++, but knows nothing about java.Then print out the Java documentation, goto Kinko's and make copies so that your class can have the reference material available to them, or ask your teacher to... Since he/she will need to learn the language also... But since they have programming experience they will be better able to explain the concepts of programming that you do not understand...
You can make any excuse for why it is difficult for you to learn, but in the end its totally irrelevant... If the school district cannot provide funding for class material, then instead of complaining with " I don't have a book... " start a community fund raiser to purchase those materials... Goto to the public library and see if they have resources you and your class can utilize... After all, it is your responsibility to educate yourself...
And most important of all, never ever say anything negative or limiting against yourself...
Do not insult me. If I could read my computer science book, I would. This is a statement against yourself... What does this statement tell you about yourself... You stated that I should not judge, but here you made a judgement about your own ability to learn...
To even insinuate that I skip class is an outrage to me. You should watch your tongue and not be so >quick to judge a situation.Why, do you ? Apparently I touched a nerve somewhere... But that does not matter...
Are you really concerned with what I think of you... If you are then you are a fool...
What other think or say have nothing to do with you... Do you know me, do I know you...
The answer is clear... I can give it to you... The Answer is No.
If you want to learn then learn... Read, Research, Practice and Read again... So simple...
Anyway... Have fun... Check out the tutorials, learn how to use the API documentation and practice coding...
and here are those links again...
The Java Tutorial
http://java.sun.com/docs/books/tutorial/index.html
Essentials of the Java Programming Language: A Hands-On Guide, Part 1 and 2
http://java.sun.com/developer/onlineTraining/Programming/BasicJava1/
http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/
Language Essentials Short Course
http://java.sun.com/developer/onlineTraining/JavaIntro/contents.html
Others
The Java Tutorial
http://java.sun.com/docs/books/tutorial/index.html
Tutorial Index
http://java.sun.com/developer/onlineTraining/index.html
- MaxxDmg...
- ' He who never sleeps... '

Similar Messages

  • HT4314 How do you delete other peoples hardware ie ipods from game center and then re run so they have their own identity

    Having major issues in trying to find out how to delete two ipods registered under my primary account and then re register so they have their own identity.
    Been on line, to Apple store and no success any help or ideas would be appreciated.

    I do not understand what you mean by remove hardware from GameCenter. What is is Game center are games associated with the Apple ID used for Game Center (Settings>GameCenter).
    What exactly are you trying to accomplish?

  • How do I move just a single clip in the project file and then convert that into an Mp4 format?

    Dear Assistance,
    I have a project file open.
    At the bottom  of the screen there is a horizontal film strip of images.  I have cut the images into certain segments.
    I want to select one single segment (about 1 min long) and convert only that selected segment into a mp4 format?
    Kindly inform me how the best way to go about doing that is.
    Thank you,
    Ben
    [email protected]

    In the sequence you will see the time code and a bar in line with it.
    At the end of all your edited clips in the sequence you will find that the bar ends, this bar defines the work area. 
    Drag each end of the work area bar so it covers only the clip you want to export.
    The select the exporter and select the preset you want and before you start the export where it says whole sequence change this to work area
    Then change the default name and location to whatever you want and start the export, job done

  • How do you test your new laptops?

    To the gurus or people who have researched this question:  How do you test your new laptops?
    When you get a new laptop, what do you do to test it?
    My X1Carbon might arrive in a couple weeks, and reading about all the failures and DOAs is scary. So assuming mine is not simply DOA, how do you shake out the less obvious or more obscure problems?
    I did search for this info before posting. One other person asked the question, 
    >> Would appreciate advice re optimal set-up and what testing/diagnostics to do to determine if ther...
    but no one answered.

    With testing I start with the basics and work my way to the harder stuff.
    Inspect the external condition of the machine.
    Boot and enter the BIOS before Windows. Review settings then power off.
    Boot from Acronis True Image Home backup/recovery DVD and clone HDD or SSD and thus the factory image before it's ever booted to Windows.
    Boot to Windows and look carefully at the Lenovo factory image and try to get an understanding for the Lenovo software and why it is there.  This does not include the other software from Microsoft, Google, etc.
    Create Lenovo Factory Image DVD set with Rescue and Recovery.  Throw disk set in the box or put on the shelf in case the machine is ever re-sold.
    Test all of the ports - I test every port on the machine for my expected usage.  For instance, in the case of the X1 Carbon I would confirm the mini DisplayPort connection works correctly with an external LCD panel.  If the machine had a IEEE firewire port or something, test that.  Test the USB 3.0 ports with a known working external external enclosure and verify transfer speeds.
    Test the SSD speed with CrystalDiskMark, ATTO and AS Disk Benchmark software to get a good overview of the performance.
    Install HWiNFO and look carefully at the components.  Observe turbo boosting, thermals and fan RPM over the course of a few days for battery and AC power.
    Do at least one full battery discharge and recharge.  Observe the cycle and details are being properly displayed and recorded in Lenovo Power Manager.
    Download all software and drivers from support.lenovo.com for the model being tested.  Confirm visually you have all the core components needed.  Core includes the drivers, power management driver, Power Manager, hotkeys, etc.
    Flatten the machine and install Windows or Linux from scratch.  Install drivers and software.
    Re-test ports and confirm the machine is working properly.
    Benchmark the SSD again.  Confirm no change.
    Install HWiNFO and confirm turbo, thermals and fan speeds are still proper.
    Install core applications and test them.  There may be core features in Windows that also need to be installed and tested.  For instance, Windows 8 Hyper-V for virtualization. 
    Connect any external devices you expect to use and test them.  For instance, video cameras, smartphones, mp3 players, digital cameras, printers, USB docks, etc.
    Do several battery tests with your typical applications and behavior.  The goal here is to simulate how the machine will be used in your day-to-day setting or travel scenarios.  I usually do at least three tests.  This can be rather time consuming with long battery life machines so I get a lot of other testing out of the way first.
    By the time you get to this point, if you haven't hit any major roadblocks you'll start to have a good feel for the machine, and if it is going to be a keeper or not.  The assumption here is that during this timeframe you have been observing the screen, keyboard, and trackpad performance to see if it's to your liking.  The other assumption is that you are using the machine and applications in the scenarios you are purchasing it for.
    I don't run synthetic benchmarks.  I prefer to test a machine against the scenarios I expect to use it with.  I spend most of the first week making this assessment.  If any major hardware defects are present, the machine is automatically returned.  I do not repair machines just received.  No exceptions.
    Week 2 is for ironing out any minor issues and assessing if the machine meets the requirements for the scenarios it will support.  If it does, it is kept.  If it does not, it is returned.  This week includes subjective and objective input.  You have to weigh the pros and cons for a machine against your priorities. It is rare that a machine is perfect so you have to decide the ROI for the machine.  Service and Support must be considered so week two might include a call to support for any unresolved issues.  Don't discount the service you receive during this period.
    After week two, you are likely right on top of the last day to return a Lenovo machine.  The return period is 21 days from the invoice date (I believe), not the day the machine is received so make sure you are well aware of it.  After 21 days, the machine is yours for good unless you sell it.  Decision time.
    Good luck.

  • How do you test an Alert?

    How do you test an Alert?

    Hi,
       Please find the folloing links, which will you some extent.
    Triggering Alerts
    http://help.sap.com/saphelp_nw04/helpdata/en/49/cbfb40f17af66fe10000000a1550b0/frameset.htm
    Setting up alerts
    Setting up alerts in RZ20
    Alert Management
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e04141e8-0f11-2a10-adaa-9d97b062c2df
    Alert Notification
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/90f449a8-a6db-2910-a386-d2b5999f5751
    Custom Alerts in CIC Win Client for CRM 5.0
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/601db2b2-2839-2a10-0381-8807979f6ff8
    Understanding u'r SAP EarlyWatch Alert Report
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4b88cb90-0201-0010-5bb1-a65272a329bf
    regards
    mahesh.

  • How do you test any SAP objects before a transport to the production server

    How do you test any SAP objects before a transport to the production server?

    Hi Rama Krishna,
       The actual process is develop the object in development system and unit test there with the available data.
      Then move it to Quality server where the data will be the actual replica of production and where the integration testing and ened to end testing happens and also the user acceptance testing  happens there.
    and once everything is found fine there then it is moved to production system.
    Award points if this is helpful.
    Regards,
    Ravi G

  • How do You Test EMail Connectivity?

    How do You Test EMail Connectivity?
    Once you setup the mail gateway with an IP address, port, and domain name.  How can you test email connectivity?  How do you force the MARS Appliance to send an email?

    There is no "test e-mail connectivity" button/function. Essentially you need to configure inspection rules to notify you when they are fired by mars.
    You will need to setup a user (preferably a non-admin account for testing) under "Management"-"user management"(if you haven't already done so) make sure to supply e-mail address.
    http://www.cisco.com/en/US/docs/security/security_management/cs-mars/6.0/initial/configuration/setup.html#wp1030836
    Now you can "Configure a Rule to Send an Alert Action." the following link explains how to do this...An easy one would be the "System Rule: CS-MARS Login Failures - Non-Admin User" rule. Follow the instructions in the link below under the "Configure a Rule to Send an Alert Action" section to modify the rule mentioned above. Keep in mind that this rule only fires when there are login failures. Once you have modified this rule try logging into mars using the non-admin user with a bad password...you should get a e-mail from MARS.
    http://www.cisco.com/en/US/docs/security/security_management/cs-mars/6.0/user/guide/combo/alerts.html#wp1056101
    Hope this helps.
    Dustin Suko

  • How do you test your Java Pricing UserExits in eclipse?

    How do you test your Java Pricing UserExits in eclipse?

    do you have to deploy the java class on vmc server to debug it
    Yes
    - So, the classes have to be compiled error free and uploaded to VMC.
    - VMC has to be restarted to test your classes.
    - You have to set the log levels appropriately for your classes using SM53 / SM52.
    -  You can also perform VMC debug through Eclipse.
    all of the details are available in the pricing exit manual*

  • How Do You Test a Flash Drive for Errors Using OS X?

    HI. In Windows there are Flash Drive tester that tests if there's something wrong with the Flash drive's chips. How do you test a flash drive for errors on OS X? I bought the HP v220w which is tiny for a 16GB and it's metal. The whole thing goes into the plug. Design wise, it is great, it's very elegant like a jewelry. Thanks in advance.
    Gbu.

    Format it for OS X and run a surface scan on the partition. That should show any hardware problems that don't keep it from working altogether.

  • How can you prevent the mac book pro from unexpectedly shutting off and beeping three times repeatedly?

    How can you prevent the mac book pro from unexpectedly shutting off and beeping three times repeatedly?

    The three beeps are an indication of a hardware problem. Power On Self-Test Beep Definition - Part 2 - Apple Support

  • How can you tell if a pic hasnt been tagged by iPhoto, and do you then...

    How can you tell if a pic hasnt been tagged by iPhoto, and do you then do you then have to draw "missing box" around them
    What I mean is tagged a few faces, imported some more pics, checked a few and they dont show as named faces, but are faces that are in my Faces source list (ie identified and named)
    So do I then have to draw a box around known faces to me, and name them again (I think iPhoto will pop up as Im typing the names I already have)
    It just means that even when i import and it doesnt name, I may have lots of pics that are of faces but not tagged and so not in my faces source list
    please help
    cheers
    ps when are Apple going to upload the Getting Started manuals for iLife 09? its been a while since released now, ad they give a bit more insight than the video tutorials alone

    No-one? It'll be nice to know how many pics of faces that arent yet tagged
    cheers

  • How can you make the iPod tell the diff between a movie and music video

    Greetings!
    How can you make iPod tell the difference between a Music Video and Movie? Everything I put up on the iPod falls into Movie. So is it something I have to do in iTunes?
    Thanks for the help!

    Rightclick the video in iTUnes, hit Get info then the "Options" tab. Beside kind you can set it to movie. music video. or TV show

  • How can you turn your iDevice on remotely because it is offline and i cant track it through find my iphone app

    how can you turn your iDevice on remotely because it is offline and i cant track it please help

    You can not turn on an iDevice remotely.

  • How do you scan in a PDF form to make it electronic and have the fields electronic?

    how do you scan in a PDF form to make it electronic and have the fields electronic?

    If you have Acrobat, you can create a PDF from a scan by selecting: File > Create > PDF from Scanner
    This is for Acrobat 11. Previous version of Acrobat have something similar.
    In order for Acrobat to be able to automatically add form fields, you will have to at least perform OCR on the PDF, but I would not expect good results. There's only so much it can do and starting from a scan is iffy. You will probably have to create the form fields yourself using the various form tools in form editing mode: Tools > Forms > Edit

  • How can I add three binary numbers and then convert to string (Hex format)?

    Hi All,
    I have my problem "half" resolved, but need some assistance on the final piece.  Overall, I need to take three string values (hex format), convert them to binary, add them and then convert back to a string (hex format).  If that doesn't make sense maybe this will:
    Final Result (My target) = 0xCC
     = 0x03 + 0x01 + 0x04
              = 0x03; 0011b
              = 0x01; 0001b
              = 0x04; 0100b
    For my app, we are dropping "masking" some of the bits so that we get 1 byte:
              = 0x03; 11b
              = 0x01; 001b
              = 0x04; 100b
    So...
    11001100b = 0xCC
    In my VI, I am taking each initial string [0x03,0x01 and 0x04] type casting them to U8.  Next I need to "mask" the binary values as shown above and then add them.  I am not sure how to do this in LV??
    Thanks for the help,
    Bryan

    Hi Bryan,
    there's a conversion palette in the string palette, ever looked at those functions?
    The rest is pure simple math:
    It's the straight-forward way, there are other possibilities too!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

Maybe you are looking for

  • I am unable to publish using Dreamweaver CS6 if I select a folder

    I can publish Ok to main directory, but if it select /public-html it  does not work. Tried witnhout the slash too. It's a Centos 6.4 x 64 running Apache.  Set up web sites with webmin/virtualmin and chanmged permissio0ns to 777 in case that was the p

  • How do I set the page that a new tab opens to?

    When I open a new tab, the tab opens automatically to Bing or some search engine other than what I have set as my home page which is set to Google. How do I get a new tab to open to my homepage and not something else?

  • Help with favicon.ico!

    I'm using SSL with tomcat and I'm having problems with firefox. When I log into the site using j_security_check I get forwarded to favicon.ico. IE doesn't have this problem, only firefox. I've done a little reading and I've seen people fix it under a

  • High Spec New iMacs *ARE* More Expensive!

    Ok, so I finally took the decision in mid-February that I couldn't wait another minute for the new iMac range to come out. I forked out for a top-spec iMac of the (now) previous generation. Imagine my dismay when just 20 days later, the new range was

  • CAN´T INSERT PHOTOS TO POWER POINT & WORD

    I have photos now installed in my Mac, but can´t see the photos archive in power point . If I use keynotes it´s okay but the problem is power point, word.... Can anyone please help me! Thank you.