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

Username:   Password: 
 RegisterRegister   
 What is wrong with this program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
illzidaneyou




PostPosted: Tue Jan 13, 2009 6:45 pm   Post subject: What is wrong with this program

this is my friends turing project
but for sum reason it dun work
i have no idea, i am not that gud at turing
it keeps getting error when u run it

Turing:
%Math output
function maxlist (list: array 1.. * of int, listlength: int): int
    %Finds the largest element of list
    var maximum := list (1)
    for i: 2..listlength
        maximum := max (maximum, list (i))
    end for
    result maximum
end maxlist
proc barchart (item: array 1..* of int, itemcount:int)
    %Draws a bar chart representing array item
    const charleft := maxx div 2
    const chartlow := maxy div 2 + 20
    const chartwidth := maxx div 2
    const chartheight := maxy div 2 - 30
    const barspacing := round (chartwidth / itemcount)
    const barwidth := barspacing - 3
    const barheightscale := chartheight / maxlist (item, itemcount)
%Creating the output colour of the bars
    for i: 0..itemcount - 1
        const barleft := charleft + i * barspacing
        const barheight := round (item(i+1) * barheightscale)
        const Colour := i mod maxcolour + 1
        drawbox (barleft, chartlow, barleft + barwidth, chartlow + barheight, Colour)
        if barheight > 0 then
            drawfill (barleft + 1, chartlow + 1, Colour, Colour)
        end if
    end for
end barchart

cls
var  mathoption : int
loop
    put "Press 1 to view a bar graph of your monthly payments."
    put "Press 2 to solve x."
    get mathoption
    case mathoption of
label 1:
maxlist
barchart

%Displaying the questions
setscreen ("graphics")
var expense: array 1..8 of int
put "Enter monthly expense to nearest dollar"
put "Rent(Output Colour Blue): "..
get expense(1)
put "Food (Output Colour Green): "..
get expense(2)
put "Clothing (Output Colour Aqua): "..
get expense(3)
put "Insurance (Output Colour Maroon): "..
get expense(4)
put "Car Cost (Output Colour Purple): "..
get expense(5)
put "Taxes (Output Colour Gold): "..
get expense(6)
put "Utilities (Output Colour Black): "..
get expense(7)
put "Entertainment (Output Colour Gray): "..
get expense(8)
barchart (expense, 8)

label 2:
put "Working on it"
end case
end loop
var back : string
put "Type 'back' to go back to main menu"
loop
    get back
    exit when back = "back"
end loop



Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
jbking




PostPosted: Tue Jan 13, 2009 7:19 pm   Post subject: RE:What is wrong with this program

How does one get out of the first loop? That would be my suggestion for a starting point on one of the errors there.
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: