Solved

Input validation code in Pascal

Posted on 2002-05-13
6
397 Views
Last Modified: 2010-04-17
Dear Programmers

Could you please supply me with a piece of code in Pascal (Turbo 7) to answer the following problem:

Ask the user to input a number.  If the number is less than 0 or more than 100 the user is asked to
re-enter the number.
0
Comment
Question by:cybernursery
6 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 7006599
Or did you misunderstood the teacher?

We're not allowed to do your homework. I'm sorry if my messages were a bit weird and stupid, but we're not allowed to do that for you. Homework is intended to be made by you as to learn from it...

CJ
0
 
LVL 48

Expert Comment

by:dbrunton
ID: 7006702
It's a repeat loop



repeat

code

until  number_meets_requirements

OK, now you have to work out what number_meets_requirements is.

Hmm, if this is homework or schoolwork which is what it seems, you have serious problems if you don't understand this type of pascal construct.
0
 

Accepted Solution

by:
eddiejr earned 50 total points
ID: 7007139
That's the answer:

program GetNumber;

var
  Number: integer;
begin
  write('Enter a number (0..100): ');
  repeat
    readln(Number);
  until (Number > 0) and (Number < 100);
end.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Expert Comment

by:nrico
ID: 7008471
eddie... :(

If people will keep doing his work for him he'll never learn to do something this simple himself.
0
 

Author Comment

by:cybernursery
ID: 7009518
First of all thanks to eddiejr,   I was aware of the code but I wanted to be sure that I answered correctly.  This was my first time.  Next time I paste the code and ask for your comments.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7009536
Both of you violate EE's rules. I will inform community support about this.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question