Solved

Input validation code in Pascal

Posted on 2002-05-13
6
364 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 47

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now