0
   

Validation question in pseudocode

 
 
Reply Mon 5 Mar, 2012 11:12 am
I need to write pseudocode to, in part, read a value and validate if it is indeed two alphas followed by four numerics, ie AA1234. How would that line of pseudocode look? Thanks so much.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 4,636 • Replies: 6
No top replies

 
View best answer, chosen by ross82573
Fido
 
  -2  
Reply Mon 5 Mar, 2012 11:37 am
@ross82573,
I don't know... Does it have some relation to reality??? It cannot be code if it is wrong or random...
0 Replies
 
George
 
  1  
Reply Mon 5 Mar, 2012 12:34 pm
@ross82573,
Maybe something like this . . .

Code:set index to string length
set result to TRUE
for index >= 0
if index > 1
if not numeric char
set result to FALSE
exit for loop
end if
else
if not alpha char
set result to FALSE
exit for loop
end if
end if
end for
ross82573
 
  1  
Reply Mon 5 Mar, 2012 05:40 pm
@George,
Thanks George -- it just seems so involved, you know? as in too many lines of pseudocode.......ugh I hate this.

The question says:

"design a program that will read the parts of an inventory file, validate the part number on each record, etc etc."

The instructor gave us a nugget that said "the part number is 6 characters. two letters followed by 4 numbers. AA1234 for example. Check that the first 2 are alphas and the last 4 are numbers"

I remember back in high school when I wrote BASIC that you were able to count back characters and check if those (like the 4th unit or whatever) was a number or letter or whatnot. That's what I am looking for in this......you know?
George
  Selected Answer
 
  2  
Reply Mon 5 Mar, 2012 05:49 pm
@ross82573,
ross82573 wrote:
. . . I remember back in high school when I wrote BASIC that you were
able to count back characters and check if those (like the 4th unit or
whatever) was a number or letter or whatnot. That's what I am looking for
in this......you know?

In the pseudocode the "4th unit or whatever" is the index into the
string (the part number). Indexing is from zero where zero is the first
character in the part number. Index zero and one must be characters,
the rest mus be numerals. You would write this as a subroutine called
with a pointer to the part number as input and the result as the output.
It assumes that there are utilities which can determine the length of the
string and whether a character is alpha or numeric.
ross82573
 
  1  
Reply Mon 5 Mar, 2012 06:02 pm
@George,
Thanks so much, I really appreciate it!
George
 
  1  
Reply Tue 6 Mar, 2012 06:45 am
@ross82573,
You're welcome, ross82573.
0 Replies
 
 

Related Topics

 
  1. Forums
  2. » Validation question in pseudocode
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.29 seconds on 11/12/2024 at 02:23:15