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

Username:   Password: 
 RegisterRegister   
 spacing glitch
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
goroyoshi




PostPosted: Sat Apr 09, 2011 4:20 pm   Post subject: spacing glitch

code:

%declaration Section
var num1, num2, num3 : int
var input : string

%Program Title
proc title
    locate (1, 30)
    put "Math testing program"
    put " "
end title

%program introdution
proc intro
    title
    put "This program will do all four math functions with three numbers entered by you"
end intro

%User Input
proc userInput
    locate (5, 1)
    put "Enter an integer: " ..
    loop
        get input
        exit when strintok (input)
        put "Please enter an integer"
    end loop
    num1 := strint (input)
    put "Enter a second integer: " ..
    loop
        get input
        exit when strintok (input)
        put "Please enter an integer"
    end loop
    num2 := strint (input)
    put "Enter a second integer: " ..
    loop
        get input
        exit when strintok (input)
        put "Please enter an integer"
    end loop
    num3 := strint (input)
end userInput

%Output - Math Calculation & Chart Titles
proc display
    var answer : real
    locate (8, 30)
    put "Math equation " : 15, "Result"
    %Addition
    answer := num1 + num2 + num3
    locate (10, 30)
    put num1, " + ", num2, " + ", num3 : 10, " = ", answer
    %Substraction
    answer := num1 + num2 - num3
    locate (11, 30)
    put num1, " + ", num2, " - ", num3 : 10, " = ", answer
    %Multiplication
    answer := num1 + num2 * num3
    locate (12, 30)
    put num1, " + ", num2, " * ", num3 : 10, " = ", answer
    %Division
    answer := num1 + num2 / num3
    locate (13, 30)
    put num1, " + ", num2, " / ", num3 : 10, " = ", answer
end display
intro
userInput
display
%End of program


why is it that the third number is spaced far away
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Apr 09, 2011 4:31 pm   Post subject: RE:spacing glitch

because that's how this code formats the output.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: