Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If...then Reserve?

Status
Not open for further replies.

NeoGenX

Programmer
Sep 18, 2003
1
US
I am really new to Pascal I am a junior at Sprague High School and i am looking for some help?

I am writing this program to have the user Input there name and age and then the comput outputs if they can vote or not..

BUT

This is my procedure for outputting Vote Or not.
Procedure Output( Name : String; Age : Integer );

Begin


If ( age < 18) {or (age = 18)} Then

Write(' You Can Vote ' , Name , '! ')

else

If (age > 18) or (age = 18) Then

Write(' Sorry Cant Vote Yet...');



end;

Now when i run it it works and i input a name..and an age..but when i input an age over 18 like say i do 24 it still says that i cant vote...I am sure its something simple but god its a mind boogler i am getting frustrated and this stuff is do tomorrow morning first period.

thanx alot :-
 
Maybe the number you pass as age is wrong. Add the following line to the beginning of your procedure:
Code:
writeln('Your age is ',age);

Note also that the operators
Code:
>=
and
Code:
<=
exist (greater or equal and smaller or equal respectively).

In your else clause you don't have put an if again: the else clause can only be reached when age is greater or equal to 18, so you don't have to check on that again.

Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
Don't worry what people think about you. They're too busy wondering what you think about them.
 
You've got the ifs the wrong way round if you want it to write that you can vote only if 18 or over. The way you've written it, it will say you can vote if less than 18. Otherwise it's fine! (but Bert is right about everything he says, too!)

 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top