Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

help with q basic

help with q basic

help with q basic

I have a string of code. I need to be able to enter a series of numbers, in no particular order, and then display the highest and lowest number. After a -99 is entered I need it to end the WHILE loop. What I have makes it loop, but when I enter the -99 it does not end the loop and display the bottom half of the code

' Declaration
numberEntered = 0
largestNumber = 0
smallestNumber = 999999

' Input the Weight of the Package
PRINT "Largest and Smallest"
PRINT "Enter a series of numbers and displays the highest and lowest number."
PRINT "The numbers do not have to be entered in any special order."
PRINT "The number must be less than 1 million."
PRINT "Enter -99 to end the program."
INPUT "Enter your first number "; numberEntered

'Execute the while loop until a -99 is entered as the number
WHILE numberEntered <> -99
IF numberEntered > largestNumber THEN
largestNumber = numberEntered
IF numberEntered < smallestNumber THEN
smallestNumber = numberEntered
INPUT "Enter your next number "; numberEnterd

'Display the largest and smallest numbers
PRINT "You entered a series of numbers."
PRINT "The largest number is ; largestNumber"
PRINT "The smallest number is ; smallestNumber"

RE: help with q basic

It does exit, but into the first loop. You have two loops; a DO..LOOP surrounding a WHILE..WEND. Take out the WHILE..WEND and replace it with a DO..LOOP UNTIL and you should be set. Also, the IF..THEN logic is not blocked properly. If the IF..THENs are not meant to be nested, make sure you end an IF..THEN statement before another one starts.


   INPUT "Enter your next number "; numberEntered
   IF numberEntered > largestNumber THEN
      largestNumber = numberEntered
   IF numberEntered < smallestNumber THEN
      smallestNumber = numberEntered
LOOP UNTIL (numberEntered = -99) 


"I do not offer answers, only considerations."
- Geates's Disclaimer


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close