Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 turing help - outputting numbers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
genie




PostPosted: Tue Jan 06, 2004 8:13 pm   Post subject: turing help - outputting numbers

Hi, i'm doing this assignment, where its a maintenance, payroll program. the user has a menu and one field is employee number. the number has to be a 5 digit number, but if the user enters 12 it needs to output 00012 in the space. how do i get the extra zeros??? i am doing a function that will go to where it's being inputed, check to make sure its 5 or less numbers and then result it back to the main program, but how do i change it to a five digit number with the zeros to be the result??? please help!! thanks
Sponsor
Sponsor
Sponsor
sponsor
Thuged_Out_G




PostPosted: Tue Jan 06, 2004 8:26 pm   Post subject: (No subject)

result "000", number
AsianSensation




PostPosted: Tue Jan 06, 2004 9:15 pm   Post subject: (No subject)

you can always use the intstr and strint convert the number back and forth from strings.

here:
code:

var num : int
var strnum : string

get num
strnum := intstr (num)

if 5 - length (intstr (num)) > 0 then
    for rep : 1 .. 5 - length (intstr (num))
        strnum := "0" + strnum
    end for
    put strnum
end if
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: