Prompt the error message according to what the user had entered.

               for(int i = 0; i<3; i++){     
                    do{                              
                         try{
                              System.out.print("Input range for Question " +(i+1) +": ");     
                              inputQuestionRange = Integer.parseInt(input.nextLine());
                         }     catch(NumberFormatException e){
                                   System.out.println("Error: Please enter a valid number.");
                              if(inputQuestionRange > 5 || inputQuestionRange <2){
                                   System.out.println("Error: Please Range enter between 2 to 5.\n");
                    }     while(inputQuestionRange > 5 || inputQuestionRange <2);     
                         question[i] = new int[inputQuestionRange];
               }//for rangeResult:
Input range for Question 1: 2d
Error: Please enter a valid number.
Error: Please Range enter between 2 to 5.
Input range for Question 1:
I would like to prompt the error message according to what the user had input.
However when user input *2d* it just print both error message as it went into the if-else block. how can i skip the if-else block ???

               //Set Range
               for(int i = 0; i<3; i++){     
                    do{                              
                         try{
                              System.out.print("Input range for Question " +(i+1) +": ");     
                              inputQuestionRange = Integer.parseInt(input.nextLine());
                                   if(inputQuestionRange > 5 || inputQuestionRange <2){
                                        System.out.println("Error: Please Range enter between 2 to 5.\n");
                                   }     else{
                                             System.out.println("OK");
                         }     catch(NumberFormatException e){
                                   System.out.println("Error: Please enter a valid number.");
                    }     while(inputQuestionRange > 5 || inputQuestionRange <2);     
                         question[i] = new int[inputQuestionRange];                    
               }//for rangeResult:
Input range for Question *1*: 22
Error: Please Range enter between 2 to 5.
Input range for Question *1*: d
Error: Please enter a valid number.
Input range for Question *1*: 3
OK
Input range for Question *2*: ww
Error: Please enter a valid number.
Input range for Question *3*:
Hi, thank you for your help, i just realize another problem.
why does my Question number increment to 3, it should remain as 2 when i request for user input again. i try many ways by altering the for loop, when i insert the try & catch block in a while(!invalid), it just loop forever and crash. How can i solve this ?
Edited by: metaroot on Feb 18, 2008 1:55 PM

Similar Messages

  • When trying to uninstall iTune (because the current install has problems), I get the error message 2324.  What should I do to reinstall the application?

    When trying to uninstall iTune (because the current install has problems; iTune error message states it cannot sync and that I should reinstall the application; also, it fails when I tried to upgrade to the latest release), I get the error message 2324.  What should I do to reinstall the application?

    That installer error is a "Can't open file" error
    It suggest that you may have a corrupt file.
    Try running a disk check
    http://windows.microsoft.com/en-US/windows7/Check-a-drive-for-errors
    If it fixes errors try uninstalling iTunes again.
    If that doesn't work, is it possible for find out the name of the problem file, is further information available? Try looking in your Action center - that's on the control panel. Another place is in the Windows Error logs. From the start menu , right click on "Computer" and select manage, then Event viewer.
    If nothing emerges, try a manual uninstall of iTunes and related programs according to this method:
    http://support.apple.com/kb/HT1923
    Don't worry if an uninstall fails, that is expected. Go on to the part where you have to delete files (2. Verify iTunes etc completely deleted) . Hopefully you manage to find a file that can't be deleted, that is the one we will need to deal with.

  • Just recently on my IPad I can't update my App. I keep getting the error message "invalid Address" what is going on?

    Just recently on my IPad I can’t update my App. I keep getting the error message “invalid Address” what is going on?

    There are a number of threads about this - it looks like Apple recently updated their address validation. Some people have recorded success by :
    ensuring that their iTunes account address is exactly the same as appears on their credit card bill
    putting something in the second line of the address (including just copying the first line)
    expanding abbreviations e.g. St to Street, Ave to Avenue etc (or conversely abbreviating)
    putting apartment or suite number on the second address line

  • Some of the songs I have downloaded onto i tunes won't play when I select it to do so.  The error message I get is "The song could not be used because the original file could not be found.  Would you like to locate it?"  How can I get my songs to play?

    Some of the songs I have downloaded into i tunes won't play when I select it to do so.  The error message I get is "The song can not be used because the original file can not be found.  Would you like to locate it?"  When I select yes I'm sent to a screen that has my i tunes library listed.  When I select the song in question I'm asked if I would like to open the song.  When I select this option I get nothing.  The songs I have downloaded must be somewhere because they are listed in my i tunes library and on the screen I've been sent to.  I can't the songs to play however.  This is not true of all of my songs but it is true of quite a few of them.  Actually, one song is too many.    How do I get my music to play that seems to be locked up somewhere in the computer?

    Presuming they're on your computer, right click on them and then follow the prompts to locate hte file on your computer.

  • My iPod touch 4th gen. Keeps giving me the error message "cannot connect to the app store when I sign in. I can open the app store and browse it but I can't download anything. I have full signal strength with my wi-fi and safari is working perfect.

    My iPod touch 4th gen. Keeps giving me the error message "cannot connect to the app store when I sign in. I can open the app store and browse it but I can't download anything. I have full signal strength with my wi-fi and safari is working perfect. I turned it off and restarted it 3 times now. I have an iPad 2 and the app store works flawlessly with it. What is going on?

    Same here on my lpad2. Can access the web just fine from browsers but cannot install new apps or updates in appl store.  Seeing a few others reporting same issue tonight so likely an apple server issue and staff will notice it in network monitors and fix it...sometime this weekend.
    Rob

  • I cannot back up my i pad to my iTunes, but the error message is not always the same.

    I cannot back up my i pad to my iTunes, but the error message is not always the same. I get everything from could not back up "because the iPad disconnected" to could not back up "because the iPad was not set up."
    Here are things I tried that did not help:
    1) I turned my iPad off then turned it back on.
    2) I backed up my iPod touch to see what happened, and it went fine.
    3) I tried a different cord to connect the computer to the iPad.
    4) I updated my iPad
    5) I updated my iTunes
    Any other suggestions? Thanks!!

    There are multiple places where these photos could be stored:
    - a recent iCloud back up
    - on your PC/Mac if you imported them
    - Photostream if you used it
    Unfortunately if the photos are not stored in any of these locations then they have been lost for good.
    All the best

  • I have disabled pop ups in my iphone but still i could n't connect to my college wifi.. It shows the error message  as ensure whether the pop ups are not blocked.. pls help

    Hai..
    I have disabled block pop up in my iphone 5s.. but still i couldn't connect my mobile with my college wifi.. it shows the error message as "ensure all the pop ups are not blocked"....

    You might want to talk to the IT dept. at your school to see if they know of a solution.

  • Working in Windows 8.1, trying to open Lightroom 3.6 64 bit, get the error message: Windows cannot access the specified device, path or file.  You may no have th appropriate permissions to access the item.

    Working in Windows 8.1, trying to open Lightroom 3.6 64 bit, get the error message: Windows cannot access the specified device, path or file.  You may no have th appropriate permissions to access the item.  I have changed the permissions to everyone and it doesn't work

    Any suggestions please?

  • [svn:bz-trunk] 15217: Bug: BLZ-508 - If server receives message for an unknown destination it shouldn ' t include the destination name in the error message sent back to the client .

    Revision: 15217
    Revision: 15217
    Author:   [email protected]
    Date:     2010-04-05 03:43:36 -0700 (Mon, 05 Apr 2010)
    Log Message:
    Bug: BLZ-508 - If server receives message for an unknown destination it shouldn't include the destination name in the error message sent back to the client.
    QA: Yes
    Doc: No
    Checkintests: Pass
    Details: Changed the error message to not include destination id. I'm also checking in a few minor fixes I had locally.
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-508
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/errors.properties
        blazeds/trunk/modules/core/src/flex/messaging/MessageBroker.java
        blazeds/trunk/modules/core/src/flex/messaging/cluster/JGroupsCluster.java

    Thanx Mete, yeah i did...
    but i solved it some other way... not entirely sure this was
    it though as i was doing a lot of things at once...
    it was fds.swc... possibly it was out of date or missing.

  • I am trying to install Firefox 4 on my Mac OS 10.5.8 and I get the error message "You cannot open the application "Firefox" because it is not supported on this architecture" Help!

    I am trying to install Firefox 4 on my Mac OS 10.5.8 and I get the error message "You cannot open the application "Firefox" because it is not supported on this architecture" Help!

    Firefox 4 requires at least OS X 10.5 and an Intel Mac. There is a third party version of Firefox 4 that runs on OS X 10.4/10.5 and PPC Macs, for details see http://www.floodgap.com/software/tenfourfox
    If you prefer, you can get the latest version of Firefox 3.6 from http://www.mozilla.com/en-US/firefox/all-older.html
    Mozilla are working to prevent Mac users with non-compatible systems from getting the notification about Firefox 4, and also not displaying the "Download Firefox 4" button on http://www.mozilla.com

  • I am getting the error message "cannot communicate with the server" when i try to sign into my apple account on my ipad - any ideas???

    i am getting the error message "cannot communicate with the server" when i try to sign into my apple account on my ipad - any ideas???

    Welcome to the Apple Community.
    The following article(s) may help you.
    Photo Stream ToU's

  • I want to de-install mac-excel test version and get the error message: you have not the privileges to de-install. Please login with the Mac-OS account you have installed mac-excel originally'. I don't know this account anymore. I am sysadm

    I want to de-install mac-excel test version and get the error message: 'You have not the privileges to de-install. Please login with the Mac-OS account you have installed mac-excel originally'. I don't know this account anymore. Possibly it does not exist anymore. anybody out there who can help ?

    Hi, I may suggest to activate the root account and try the uninstall process from that account. To do so, you have to:
    Go to System Preferences a open up the Users pane;
    On the left side of the pane, you shuold see Login Options;
    Enabled editing option clicking on the lock (it will ask your password);
    Once the pane is enabled, you should see something like Server Account Network (sorry my OS is in italian, so I don't exactly know the right translation), and right next to it a button;
    Click on that button, and a new pane shows up. Click on Open Directory Utility, and on the upper bar of OS X click on Edit;
    Select Enable Root Account (you can set a password, or not);
    Done that, you should log out and when the login window show up, type on the user field "root" and the password you choose;
    Theorically, from this account you will be able to unistall the application.
    After completing your task, I reccomend you to disable the root account, just by loggin in your personal account and repeating the steps I described before. Hope it helps

  • After getting 4G with AT&T I am unable to join my network and get the error message: Unable to  join the network "Jude". How do I fix this? Thank you

    After getting 4G with AT&T I am unable to join my network and get the error message: Unable to  join the network "Jude". How do I fix this? Thank yo

    Try power-cycling your wireless router (unplg for 30 seconds, plug back in).  Here's a longer list of troubleshooting steps: http://support.apple.com/kb/TS1398.

  • When ever I try to export to Perfect Effects 8 a DNG Photo this is the Error message "Unable to complete the export. One or more files could not be found" Any one know how to fix this?

    When ever I try to export to Perfect Effects 8 a DNG Photo this is the Error message "Unable to complete the export. One or more files could not be found" Any one know how to fix this?@

    Adobe web chat come up with a solution.
    Open the PP project.
    Export your sequence or project as a Final Cut Pro XML file.
    Set up a new PP project.
    Import the Final Cut Pro XML file.
    This will get you back up an running.
    Since getting back to editing this project I have found that some things will be lost or change in using XML:
    You will lose position key framing, black video clips, dissolve fx, audio levels, audio dynamic fx, the ability to open a multi camera clip and change the camera view.
    You will keep cut points, crop fx.
    Not perfect but only took a couple of hours to save 3 days work.

  • Help! My iPhone 4 can not be switched on as it went off while updating. The error message come up on the itune screen to restore the phone but it can not be restored. Now I want just the phone to be on so I can use it!!!!

    The error message come up on the itune screen to restore the phone but it can not be restored. Now I want just the phone to be on so I can use it!!!!

    Hey!
    I have tried holding down the home and power button countless of times. It doesnt respond at all. Plug my phone to a charger and hold down the power button and my phone switched on. But it said Activation Required and said connect to Itunes. As e screen remains on the connect to Itunes screen, I disconnect the charger from my phone and my phone went dead instantly. My battery is full btw. Tried connecting to Itunes through my Macbook Pro but iTunes doesnt detect my device and the apple logo flashes for about a few seconds on my phone and then disappear and then came back on again. My Iphone has been connected to my laptop for about 30 mins and the apple logo has been coming on and off for 30 minutes now and Itunes has not detect my device yet.
    SIGHHH.

Maybe you are looking for