Why doesn't the loop exit?

I have my program prompting the user for a code in letters.
System.out.print("Enter Code: ");
code = TextIO.getlnString();
code = code.toUpperCase();
//uppercase so I don't have to code for small letters tooFollowing this I'm using a while loop to check if the code contains numbers or anything other than letters.
hecknum = (int) code.charAt(p);
while ((checknum >= 91) || (checknum <= 64)) {
System.out.println();
System.out.println("Codes may only contains letters from A to Z.\n");
System.out.print("Enter Code: ");
code = TextIO.getlnString();
code = code.toUpperCase();
}This only works partially however. If I enter letters the first time through, everything will work fine.
If I enter numbers or some other symbols, I get the error and am re-prompted for the code. Thing is, if I enter only letters the second time around, I get the error message again, as if I had entered numbers or something.
I have no clue why... from what I see it should work...
Can anyone help me figure this out?

inside the while loop you never change the value of checknum, so if the codition is tru when you enter the loop, it stays true
looks like you need to change p and recalculate checknum

Similar Messages

  • Why doesn't the role of IP in portal exit?

    Hi,
      Why doesn't the role named 'pcdportal_contentcom.sap.pctplatform_add_onscom.sap.ip.biRolescom.sap.ip.bi.bi_showcase' for IP exit in portal. But the t-code RSPLAN workds.
      Any suggetions are appreciated.
    B.R
    Gerald

    It's due to the JCO configration.

  • Why doesn't the result look right when comparing?

    Why doesn't the result look right even I used higlight execution to check true and false and found to be correct right?
    Attachments:
    comparenresult.zip ‏27 KB

    At first I was not sure what you were asking. After looking more closely, I think I can answer your question.
    First of all, you need to initialize your shift register. This is the array of Boolean results. The first time through it works OK, but subsequent runs are also added on instead of replacing the results, even though you used a local to "clear" the array first.
    You are adding 2 to the iterations and indexing on the new number. This is a so that you skip the first two "bad" values. Therefore, you only have 13 data points and should only be running the FOR loop 13 times. Change the FOR loop count constant to 13 (or get the array size and subtract 2 and wire it in if the number of tests is variable).
    Also, there is an 'In Range a
    nd Coerce' node that will perform the two tests and the AND all in one node. This was not an error, of course, but it does make it a bit easier to read.
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]
    Attachments:
    fixed_test4a.vi ‏73 KB

  • Why doesn't the iPad have a guest screen like the PC for extra security?

    I just want to start off first by saying I just purchased my iPad about six months ago and I'm really enjoying it,but if you're like me,I believe in protecting my privacy.
    I don't like to turn down any of friends or coworkers when I'm asked to use my iPad,but when you have such things as your personal pictures,movies,music,business documents,etc...you'd like to keep them from prying eyes. I thought that with the new iOS 7 update,that issue would've been fixed, but I was wrong. I'm hoping Apple would correct this problem with the next iOS update,it would make a lot of loyal Apple consumers &amp; anyone who's new to purchasing the iPad for the first time very happy to know that feature is available.
    Why doesn't the iPad offer a guest screen?

    Tell Apple at the link below.
    http://www.apple.com/feedback/ipad.html

  • Why doesn't the CC app work properly?

    I've been using Creative Cloud for some time now and am really loving it, however I must say it is a source of annoyance that the Creative Cloud app just doesn't work properly.
    Firstly, I used it initially to download all my apps, then after an update those apps no longer appeared in the "Apps" list. Now only those that have been installed since that update appear in this list. Why doesn't the "Apps" list display all of the Adobe CC apps that I have installed on my computer?
    Why does it keep reinstalling fonts? I'm always getting "Lush Script Regular" and other fonts being added.
    It regularly comes up telling me that Dreamweaver and Premiere Pro need to be updated, but always I get an error, then the update request disappears.
    I'm regularly getting 4 files that it can't sync - even though they are the same files as others in the folder. If nothing else, why can't I say "Great, got the message". Also, why is the error message just "due to server error" with no advice on how to resolve it? Why is there a server error on only these 4 files?
    It seems to me there are still some teething issues with the CC app, but what I don't understand is why they aren't being resolved much faster, given that this is the portal to the service.
    Of course, given Adobe I doubt I'll get satisfactory answers – a little jaded with their responses. Anyway, thought I'd at least post the questions.  

    Questapo I am sorry you have been facing difficulties with your Creative Cloud experience.  I don't believe it will be possible to address all of your concerns in one discussion.  I would not be surprised if at least three of the issues are related to the same root cause.
    First in order for the applications to be visible are you regularly needing to delete the OPM.db file?  You can find this listed as solution 2 in CC desktop lists applications as "Up to Date" when not installed - http://helpx.adobe.com/creative-cloud/kb/aam-lists-removed-apps-date.html.

  • Why Doesn't the XIRR function work?

    In Excel if you have 5 records from a1:b5 then XIRR looks like this:
    XIRR(A1:A5, B1:B5) you get a nice neat answer like .35
    Here is a version that works in Crystal that would require manual entry of any new quarters numbers and dates-- and if you plug this into Crystal it works:
    (XIRR([1000000,-100000,-100000,-100000,-100000,10277.49,-100000], [DateValue(1999,2,1),DateValue(1999,3,1),DateValue(1999,6,1), DateValue(1999,12,1),DateValue(2000,3,1),DateValue(2000,6,1),DateValue(2000,9,1)]))*.100
    You do get a nice answer of something like .035.  But this is all done manually and I need it to function automatically when the report is refreshed.
    So you have a range for the currency and a range for the date fields. I need to simulate this in crystal. Crystal has an XIRR function, and with the arrays, I should be able to fill in the range, but am having difficulty getting it to work.
    After building the arrays, I made another formula to combine the arrays in the XIRR formula.
    I am down to this error now after getting this formula this far  --
    "Numerical method did not converge; try another value for guess."
    Here's where I am with the formula, although they don't want to use the guess part of the XIRR function - they just want to use the XIRR(number/currency, date).  Maybe you could pass this on too?:
    /{@Reset} for the group header (NOT using a repeated group header):
    whileprintingrecords;
    numbervar array x := 0;
    datevar array y := date(0,0,0);
    numbervar i := 0;
    numbervar j := 0;
    //{@accum} for the detail section:
    whileprintingrecords;
    numbervar array x;
    datevar array y;
    numbervar i := i + 1;
    numbervar j := count({table.groupfield},{table.groupfield});
    if i <= j then (
    redim preserve x[j];
    redim preserve y[j];
    x<i> := tonumber({table.currency});
    y<i> := datevalue({table.datetime})
    //{@xirr calc} to be placed in the group footer:
    whileprintingrecords;
    numbervar array x;
    datevar array y;
    xirr(x,y)
    The array works correctly.  So why do I get that error and why doesn't the XIRR formula work like they say it should?  Has anyone used this successfully in Crystal--maybe you could shed some light?
    Thanks!

    Hi,
    I am receiving that same error when the last item in the array is 0, otherwise all works perfectly.
    When I run the same group of numbers and dates in Excel it returns without issue.
    -265500.00,-690000.00,-570000.00,16814.25,-855000.00,-619500.00,55293.46,30411.40,15183.76,  0.00
    01-25-2007,03-06-2007,05-02-2007,06-29-2007,08-01-2007,08-24-2007,09-17-2007,03-14-2008,05-28-2008,03-31-2010
    =XIRR(A2:J2,A1:J1,-0.1)
    Is there a known bug in Crystal's XIRR function when the last value is 0? 
    Or a hot-fix that will repair this?
    Thanks in advance,
    Gary
    PS. I am using Crystal XI Product Version: 11.0.0.2495

  • Why doesn't the location information in an iCal meeting show up on my iPhone, when it does show up in iCal?

    Why doesn't the location information show up on my iPhone 4S calendar when I accept an invitation to a meeting?
    The other information such as the date, time and invitees all show up on the iPhone, while in iCal all the information including the Location field is showing up.

    If it won't charge you probably need to try a different dock to usb cable.  More information on troubshooting this is available here:  http://support.apple.com/kb/TS1591.

  • Why doesn't the weather icon display the current temperature in your "local" city?

    Why doesn't the current temperature display in the weather icon on the home screen?

    The application works and I do have location-based services on. I'm just wondering why the icon itself does not show the current temperature. Sort of how they upgraded the clock after show the current time.

  • Why doesn't the "back" button work all the time in Safari?

    Why doesn't the "back" button work all the time in Safari?

    thanks for the reply. You prompted me to check and I realised it wasn't installed on my test laptop and opening in Microsoft Reader. I've installed it now and it works.
    My next challenge is to prevent the mailto: command opening Microsoft Mail instead of Outlook, but I guess every user will have a different default.
    Thank you

  • Why doesn't the repair box in Aperture show up? and if it does, once you choose repair does it give you an indication it is working?

    Why doesn't the repair box in Aperture show up? and if it does, once you choose repair does it give you an indication it is working?

    Winterwren22 wrote:
    Why doesn't the repair box in Aperture show up?
    Without more information, speculation is a waste of time.  At the least tell us what you do, what the results are, and how that result differs from your expectation.  Then tell us what steps you have taken to resolve the issue, and what the results of taking those steps was.
    once you choose repair does it give you an indication it is working?
    Adjustments you make are shown live.
    Instructions on the use of Repair Brush are here (ignore "Spot & Patch" -- it is superannuated).

  • I have Adobe Reader X on Windows Vista. Why doesn't the Printer for Adobe PDF show up in my Hardware/printers? Or can I add it to the Hardware/Printers?

    I have Adobe Reader X in Windows Vista. Why doesn't the Adobe PDF show up as a printer in my Hardware/Printers? Or can I add it to the Hardware/Printers? And how?

    Adobe Reader - FREE - reads PDF files, prints them, fills forms.
    Adobe Acrobat - $$ - as Reader, and makes PDFs and edits them, sorta, and does a bunch more.
    So if you had Acrobat try and find the license to avoid having to pay again...

  • Why doesn't the sd card or the usb connect to my mac ????

    why doesn't the sd card or the usb connect to my mac plzzzz help meeeeeeeeeee

    The reason no one has replied is that you posted in a little-viewed forum for an obsolete Apple software suite. I am asking the Hosts to move you to the MacBook Air forum.
    Also these forums are NOT chat rooms so you will seldom get an instant answer. No one here works for Apple; we are end users like you who volunteer on a time-available basis to help our fellow Mac users. Patience is required here.

  • Why doesn't the rotate gesture on my trackpad behave as it used to for switching between tabs when it works the same with all other programs besides Firefox?

    Why doesn't the rotate gesture on my trackpad behave as it used to for switching between tabs when it works the same with all other programs besides Firefox?
    I changed the about:config to make the rotate gesture move between tabs, and it worked great for well over a year. Now it behaves erratically as described here:
    https://bugzilla.mozilla.org/show_bug.cgi?id=877598
    It used to be very controllable to move one tab over, now it is erratic and moves quickly and to unexpected tabs regardless of how slow I do the rotate gesture. This is the main reason I use Firefox over Chrome and I would like to continue to do so unless there is no fix to this.

    Just set the browser.gesture.twist.threshold to something around 15-25.

  • HT1368 Why doesn't the Add to Wish List icon appear on my iPhone 5? I have iOS 7...frustrating

    Why doesn't the Add to Wish List icon appear on my iPhone 5? I have iOS 7...frustrating

    If it's not a free item then you should get the 'add to wish list' icon via the share button - is it a free or paid-for item that you are looking at ?

  • HT1853 Why doesn't the iTunes show your device?

    Why doesn't the new iTunes show your device? I want to sync new albums..

    when I try and put songs on it it will sit their for hours saying updating files on zachs iphone preparing to update and it never changes and never updates

Maybe you are looking for