Results 1 to 9 of 9

Thread: need help with programming question

  1. #1
    Join Date
    Dec 2004
    Posts
    476
    Rep Power
    0

    Exclamation need help with programming question

    i have a programming question but i cannot build the menu
    Johnny Kool's Enterprise
    1.Payroll
    2. Credit Card Billing
    3. Gasoline Consumption
    4. Quit
    this is what i have

    Begin
    Display_Menu(B010)
    Read Choice
    DOWHILE Choice=1 OR CHOICE=2 OR CHOICE=3 OR CHOICE=4
    CASENTRY CHOICE
    CASE "1"
    FIND_PAY(B020)
    CASE "2"
    Find_Credit(B030)
    CASE "3"
    Find_gas(B040)
    CASE "4"
    ENDCASE
    DIsplay_menu (B010)
    Read Choice
    ENDDO
    END
    the part that is giving me probs is the case 4 where it should end the program if 4 is entered. please help me!!!!
    WHY PAY WHEN YOU CAN GET IT FREE!!!!!

  2. #2
    Join Date
    Jul 2002
    Posts
    5,446
    Rep Power
    10

    Default

    You have an infinite loop taking place there. What is happening is that once you enter 1, 2, 3 or 4 you will stay in the loop (dowhile) and that is not what you want. You want to limit the loop to options 1 -3 and exit when a 4 is entered.

    Oh, and next try try to use indentation ... it helps a lot
    Team Leader
    TechJamaica.com

  3. #3
    Join Date
    Dec 2004
    Posts
    476
    Rep Power
    0

    Default

    yes thats true but how do i let 4 end the program
    WHY PAY WHEN YOU CAN GET IT FREE!!!!!

  4. #4
    Join Date
    Jul 2002
    Posts
    5,446
    Rep Power
    10

    Default

    What happens when you enter 5?
    Team Leader
    TechJamaica.com

  5. #5
    Join Date
    May 2005
    Posts
    59
    Rep Power
    0

    Default

    remove OR CHOICE=4 at the start of the loop then anything entered that is not 1, 2,3 will cause the loop to exit.

    also might I suggest that you try to use only one variable as a flag for your loop; instead of DOWHILE Choice=1 OR CHOICE=2 OR CHOICE=3 OR CHOICE=4
    try only Choice NOT= 4. I'm not sure of the syntax since I don't think I've ever seen this language before but I hope you get the idea. btw using a negative flag can be a bit complicated but i would try it in this case.
    Good luck
    "I don't believe in astrology; I'm a Capricorn and we're skeptical."

  6. #6
    Join Date
    Apr 2005
    Posts
    1,333
    Rep Power
    0

    Default

    Here's what I would do in VB, hope this helps you:

    Begin
    Display_Menu(B010)
    Read Choice
    SELECT CASE ENTRY CHOICE
    CASE "1"
    FIND_PAY(B020)
    CASE "2"
    Find_Credit(B030)
    CASE "3"
    Find_gas(B040)
    CASE else
    END SELECT
    DIsplay_menu (B010)
    Read Choice
    END
    The fox was probably right - they could have been sour grapes.

  7. #7
    Join Date
    Jul 2004
    Posts
    264
    Rep Power
    0

    Default

    OR ... u can scrap what u hav after the dowhile statement and put

    DOWHILE NOT(Choice = 4)

    and take out that case statement for '4'

  8. #8
    Join Date
    Dec 2004
    Posts
    476
    Rep Power
    0

    Default

    but the program should end when 4 is entered so what should the new program look like?
    WHY PAY WHEN YOU CAN GET IT FREE!!!!!

  9. #9
    Join Date
    Apr 2005
    Posts
    8
    Rep Power
    0

    Default

    Quote Originally Posted by akoo
    but the program should end when 4 is entered so what should the new program look like?
    As everyone above has said ... take option 4 out of the while loop, as aonekilla said you can make the condition of the while loop dowhile( choice != 4) and take out the condition for 4 in the loop the program will end like magic we promise you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •