Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Programming (http://www.go4expert.com/forums/programming-forum/)
-   -   Pseudocode review needed ;) (http://www.go4expert.com/forums/pseudocode-review-needed-t25547/)

archy_fc 17Apr2011 08:52

Pseudocode review needed ;)
 
Gday everyone!
Im brand new to the forum and have recently started programming. At the moment I think everything is going well with the learning curve mostly because its worded maths.
Anyway Ive been given the task to write an algorithm to test the Internet IP address entered by a user.
The IP consists of 4 groups of numbers, each from 0-255. The user is to enter the groups of numbers. The first number is to be tested as to what class teh address belongs to. The is to be displayed on the screen along with the full IP of the 4 numbers.

I think this is good, but have a feeling I may have muddled up the loops.
So if anyone could look over this, that would be awesome.

Cheers,
Levi

Code:

#Start code
Start IP
IP1=0
IP2=0
IP3=0
IP4=0
CLASS=X
Write to user what program does.
Prompt user for IP1
Read IP1
        While(IP1=>0)Do
                While(IP1<256)Then
                Read IP1
                Else
                Write Error Message
        End While
End While
Prompt user for IP2
Read IP2
        While(IP2=>0)Do
                While(IP2<256)Then
                Read IP2
                Else
                Write Error Message
        End While
End While
Prompt user for IP3
Read IP3
        While(IP3=>0)Do
                While(IP3<256)Then
                Read IP3
                Else
                Write Error Message
        End While
End While
Prompt user for IP4
Read IP4
        While(IP4=>0)Do
                While(IP4<256)Then
                Read IP4
                Else
                Write Error Message
        End While
End While
While(IP1<128)Then
Class=A
Else
        While(IP1<201)Then
        Class=B
        Else
                While(IP1<235)Then
                Class=C
                Else
                        While(IP1<256)Then
                        Class=D
                        Read Class
                        Else
                        Write Error Message
                        End While
                End While
        End While
End While
Display message to user
Write IP1.IP2.IP3.IP4
Write CLASS
End IP

This has been indented, but for some reason it wouldnt show it.


All times are GMT +5.5. The time now is 08:57.