
-----------------------------------
icexblood
Mon Mar 03, 2008 6:59 pm

Turing help.. This is the hardest thing :(
-----------------------------------
Ok im trying to make this program and im a nubie
it asks for how much marks you want to enter from 4-6, then averages them

var marks: real
marks:= 0
loop
    put "What are the marks you want to enter? Type stop to exit."
    get marks
exit when marks = "exit"
end loop

thats what i got so far :(

-----------------------------------
syntax_error
Mon Mar 03, 2008 7:05 pm

RE:Turing help.. This is the hardest thing :(
-----------------------------------
use an array to hold the marks. go to the turing walkthrough; learn from that ask more questions if you have. and please use code tags?!

-----------------------------------
icexblood
Mon Mar 03, 2008 7:15 pm

Re: RE:Turing help.. This is the hardest thing :(
-----------------------------------
use an array to hold the marks. go to the turing walkthrough; learn from that ask more questions if you have. and please use code tags?! ok i never learned and this i cant cos i need it now T_T

-----------------------------------
icexblood
Mon Mar 03, 2008 7:18 pm

Re: RE:Turing help.. This is the hardest thing :(
-----------------------------------
use an array to hold the marks. go to the turing walkthrough; learn from that ask more questions if you have. and please use code tags?! ok i never learned and this i cant cos i need it now T_T This is my new one 

var marks : int
var count : int
marks := 0
count := 0
loop
    put "What are the marks you want to enter? Type stop to exit."
    get marks
    marks := marks + marks
    exit when marks := "done"
    count := count + 1
end loop
put "The average mark is " marks / count

-----------------------------------
michaelp
Mon Mar 03, 2008 7:33 pm

RE:Turing help.. This is the hardest thing :(
-----------------------------------
Did you even test that code?
I don't know why I asked that, because I know you didn't. Because I just did, and it didn't work. You said "exit when marks := "done"
There are 2 things wrong with that line:

1. ':=' is the assignment operator. So your exit statement assigns marks to "done"
2. marks is an integer value. It won't run like that, and there will be an error if you try to enter it.

Download Turing and test it yourself next time.
http://holtsoft.com/Turing%204.1.1.zip

-----------------------------------
richcash
Mon Mar 03, 2008 7:34 pm

Re: Turing help.. This is the hardest thing :(
-----------------------------------
get marks
marks := marks + marks
What does that do? In your head try putting numbers in for marks and calculate what will happen. Do you see the problem? You need another variable.

exit when marks := "done"
marks is an integer. How can it ever be a string? Maybe you should tell the user to enter -1 to end inputting (unless you want to convert types).

-----------------------------------
icexblood
Mon Mar 03, 2008 7:39 pm

Re: RE:Turing help.. This is the hardest thing :(
-----------------------------------
Did you even test that code?
I don't know why I asked that, because I know you didn't. Because I just did, and it didn't work. You said "exit when marks := "done"
There are 2 things wrong with that line:

1. ':=' is the assignment operator. So your exit statement assigns marks to "done"
2. marks is an integer value. It won't run like that, and there will be an error if you try to enter it.

Download Turing and test it yourself next time.
http://holtsoft.com/Turing%204.1.1.zip
uhh i tested my new one that im working on.. Look, only 1 thing is wrong and its somethin g to do with boolean o_O
var markstotal : real
var marks1 : real
var marks2 : real
var marks3 : real
var marks4 : real
var marks5 : real
var marks6 : real
var count : int
marks1 := 0
marks2 := 0
marks3 := 0
marks4 := 0
marks5 := 0
marks6 := 0
count := 0
loop
    put "What are the 1st marks you want to enter? Type done to exit."
    get marks1
    put "What are the 2nd marks you want to enter? Type done to exit."
    get marks2
    put "What are the 3rd marks you want to enter? Type done to exit."
    get marks3
    put "What are the 4th marks you want to enter? Type done to exit."
    get marks4
    put "What are the 5th marks you want to enter? Type done to exit."
    get marks5
    put "What are the 6th marks you want to enter? Type done to exit."
    get marks6
    exit when marks1, marks2, marks3, marks4, marks5, mark6 = "done"
    markstotal := marks1 + marks2 + marks3 + marks4 + marks5 + marks6
    count := count + 1
end loop
put "The average mark is ", markstotal / count

-----------------------------------
icexblood
Mon Mar 03, 2008 7:42 pm

Re: Turing help.. This is the hardest thing :(
-----------------------------------
get marks
marks := marks + marks
What does that do? In your head try putting numbers in for marks and calculate what will happen. Do you see the problem? You need another variable.

exit when marks := "done"
marks is an integer. How can it ever be a string? Maybe you should tell the user to enter -1 to end inputting (unless you want to convert types).
ok look, this is new one
theres 1 error saying something about a boolean 

var markstotal : real
var marks1 : real
var marks2 : real
var marks3 : real
var marks4 : real
var marks5 : real
var marks6 : real
var count : int
marks1 := 0
marks2 := 0
marks3 := 0
marks4 := 0
marks5 := 0
marks6 := 0
count := 0
loop
    put "What are the 1st marks you want to enter? Type done to exit."
    get marks1
    put "What are the 2nd marks you want to enter? Type done to exit."
    get marks2
    put "What are the 3rd marks you want to enter? Type done to exit."
    get marks3
    put "What are the 4th marks you want to enter? Type done to exit."
    get marks4
    put "What are the 5th marks you want to enter? Type done to exit."
    get marks5
    put "What are the 6th marks you want to enter? Type done to exit."
    get marks6
    exit when marks1, marks2, marks3, marks4, marks5, mark6 = "done"
    markstotal := marks1 + marks2 + marks3 + marks4 + marks5 + marks6
    count := count + 1
end loop
put "The average mark is ", markstotal / count

-----------------------------------
syntax_error
Mon Mar 03, 2008 7:43 pm

RE:Turing help.. This is the hardest thing :(
-----------------------------------
that is because the "=" makes it a boolean expression and you cant compare ints with a string without casting. 

honestly you dont even need the loop

-----------------------------------
icexblood
Mon Mar 03, 2008 7:49 pm

Re: RE:Turing help.. This is the hardest thing :(
-----------------------------------
that is because the "=" makes it a boolean expression and you cant compare ints with a string without casting. 

honestly you dont even need the loop soooo how can i modify the one i have right now :(

-----------------------------------
syntax_error
Mon Mar 03, 2008 8:05 pm

Re: Turing help.. This is the hardest thing :(
-----------------------------------
jsut remove teh loop.



var markstotal : real
var marks1 : real
var marks2 : real
var marks3 : real
var marks4 : real
var marks5 : real
var marks6 : real
var count : int
marks1 := 0
marks2 := 0
marks3 := 0
marks4 := 0
marks5 := 0
marks6 := 0


put "What are the 1st marks you want to enter? Type done to exit."
get marks1
put "What are the 2nd marks you want to enter? Type done to exit."
get marks2
put "What are the 3rd marks you want to enter? Type done to exit."
get marks3
put "What are the 4th marks you want to enter? Type done to exit."
get marks4
put "What are the 5th marks you want to enter? Type done to exit."
get marks5
put "What are the 6th marks you want to enter? Type done to exit."
get marks6

markstotal := marks1 + marks2 + marks3 + marks4 + marks5 + marks6

put "The average mark is ", markstotal / count

-----------------------------------
icexblood
Mon Mar 03, 2008 8:19 pm

Re: Turing help.. This is the hardest thing :(
-----------------------------------
jsut remove teh loop.



var markstotal : real
var marks1 : real
var marks2 : real
var marks3 : real
var marks4 : real
var marks5 : real
var marks6 : real
var count : int
marks1 := 0
marks2 := 0
marks3 := 0
marks4 := 0
marks5 := 0
marks6 := 0


put "What are the 1st marks you want to enter? Type done to exit."
get marks1
put "What are the 2nd marks you want to enter? Type done to exit."
get marks2
put "What are the 3rd marks you want to enter? Type done to exit."
get marks3
put "What are the 4th marks you want to enter? Type done to exit."
get marks4
put "What are the 5th marks you want to enter? Type done to exit."
get marks5
put "What are the 6th marks you want to enter? Type done to exit."
get marks6

markstotal := marks1 + marks2 + marks3 + marks4 + marks5 + marks6

put "The average mark is ", markstotal / count
not as good as ur old one man, that one rox

-----------------------------------
syntax_error
Mon Mar 03, 2008 8:23 pm

RE:Turing help.. This is the hardest thing :(
-----------------------------------
ya well, nor array so cant do much =P

-----------------------------------
richcash
Mon Mar 03, 2008 8:38 pm

Re: Turing help.. This is the hardest thing :(
-----------------------------------
What? Don't do that! Don't you want the user to be able to enter as many values as they want?

You only need one variable for the input. You can use that variable over and over to get the input, and then add it to a separate variable to keep track of the sum each time. That is all that was wrong with the second program you posted in this thread (and the int/string issue). You just needed a separate variable for the sum.

-----------------------------------
syntax_error
Mon Mar 03, 2008 9:14 pm

RE:Turing help.. This is the hardest thing :(
-----------------------------------
richcash I did try to make icexblood use array but he hasnt done that in class yet thus he didnt wish to.

an old saying: you can only lead a horse to the water, but you cannot force it to drink.

edit: w00t a NewBe Hacker now =P

-----------------------------------
HeavenAgain
Mon Mar 03, 2008 9:20 pm

RE:Turing help.. This is the hardest thing :(
-----------------------------------
syntax_error you can do it with array, BUT its not even necessary here (unless you going to use a certain mark that was entered sometimes later in your code)

and therefore
You only need one variable for the input. You can use that variable over and over to get the input, and then add it to a separate variable to keep track of the sum each time.

-----------------------------------
syntax_error
Mon Mar 03, 2008 9:43 pm

RE:Turing help.. This is the hardest thing :(
-----------------------------------
oo yes that makes sense as well; :oops:

my mistake.

-----------------------------------
DaveAngus
Tue Mar 18, 2008 10:31 am

RE:Turing help.. This is the hardest thing :(
-----------------------------------
Here is a very simple way to do that average calculator.

There are shorter ways but if you are a newbie,
its easier to see everything nicely laid out.


This code will work very well for that.






/*
 Name : Dave Angus
 Date : Feb 21st 2008
 Title: assi2.t
 Description : This is a calculator that calculates your average.
 */

var per1 : int
var per2 : int
var per3 : int
var per4 : int
var average : real


/*
 This is where the user can enter their marks.
 */


put "Please insert your four semester I marks to recieve your average"

put " Period One Mark:"
get per1

put " Period Two Mark:"
get per2

put " Period Three Mark:"
get per3

put " Period Four Mark:"
get per4

/* This 'cls' means clear screen if you havent been taught that yet.
 */
cls


put "Your average is: ", (per1 + per2 + per3 + per4) / 4
average := (per1 + per2 + per3 + per4) / 4

/*This is the output comment
 I dont know if you have learnt if statements yet. If you havent, I can easily walk you though them.
 They are very self explanitory.

 */

if average = 100 then
    put "Your a genious!"

elsif average >= 90 then
    put "Your next to flawless!!!"

elsif average >= 80 then
    put "Great mark!"

elsif average >= 70 then
    put "Push a little harder if you want honor role!"

elsif average >= 60 then
    put "Good work."

elsif average >= 50 then
    put "You almost failed!"

elsif average 