Posted: Fri May 29, 2009 9:13 am Post subject: Need help with adding a timer
What is it you are trying to achieve?
I want my program to have a timer
What is the problem you are having?
Cant add the timer
Describe what you have tried to solve this problem
I tried using the Tuting Help, and different methods to add a timer.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing:
% The multiple choise exam % User choose one of the 4 possiable answers for each question
% The varibles that is declared var mypic :int:=Pic.FileNew("update.bmp") var answer: string var w_mark: real var point: real var i :int:=0
process playstuff
loop Music.PlayFile("music.mp3") endloop end playstuff
fork playstuff
point :=0
% Short descriptiton of the test put"This is a science exam consisting of 20 questions. Please select the most correct answer for each question."
% Test starts with a question put"Question Number #1" put"What is the last planet in the solor system" put"a) Venus" put"b) Neptune" put"c) Mars" put"d) Jupiter" get answer
if answer= 'b' then point:=point+1 else
point:=point+0 endif
put"Question Number #2" put"What is photosynthesis?" put"a) When plants absorb water from the sun" put"b) When plants absorb water from their roots" put"c) When the sun absorbs energy from the plant" put"d) When plants absorbs energy from the sun" get answer
if answer= 'd' then point:=point+1 else
point:=point+0 endif
put"Question Number #3" put"Compared to felsic igneous rocks, mafic igneous rocks contain greater amounts of" put"a) White quartz" put"b) Aluminum" put"c) Pink Feldspar" put"d) Iron " get answer
if answer= 'd' then point:=point+1 else
point:=point+0 endif
put"Question Number #4" put"The Earth's shape most closely resembles which of the following object" put"a) A basketball " put"b) A pear " put"c) A ping-pong ball " put"d) An apple " get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #5" put"The water sphere of the earth is known as the " put"a) Atmosphere" put"b) Troposphere" put"c) Lithosphere" put"d) Hydrosphere" get answer
if answer= 'd' then point:=point+1 else
point:=point+0 endif % After each 5 questions, you get told how many questions you have correctly, and how many incorrectly put" " Pic.Draw(mypic, 0, 15, 0)
w_mark:=5-point
put"You have answered ", point, " questions correctly and ", w_mark, " question incorrectly."
put"Question Number #6" put"Which factor has the greatest influence on the weathering rate of Earth's surface bedrock?" put"a) Local air pressure" put"b) Angle of insolation" put"c) Age of the bedrock" put"d) Regional climate" get answer
if answer= 'd' then point:=point+1 else
point:=point+0 endif
put"Question Number #7" put"What is percipation" put"a) When it is raining" put"b) When the water is absorbed from the clouds" put"c) When air meets water" put"d) Condensation" get answer
if answer= 'a' then point:=point+1 else
point:=point+0 endif
put"Question Number #8" put"What group is the element Potassium in?" put"a) Alkali Metal" put"b) Alkali Earth Metal" put"c) Noble Gas" put"d) Alkali Gas" get answer
if answer= 'a' then point:=point+1 else
point:=point+0 endif
put"Question Number #9" put"What does the symbol H stand for?" put"a) Helium" put"b) Hafnium" put"c) Hydrogen" put"d) Hydrigrrn" get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #10" put"How many elements are there in the Peridoc Table of Elements" put"a) 116" put"b) 120" put"c) 118" put"d) 117" get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif % After each 5 questions, you get told how many questions you have correctly, and how many incorrectly put" " Pic.Draw(mypic, 0, 15, 0)
w_mark:=10-point
put"You have answered ", point, " questions correctly and ", w_mark, " question incorrectly."
put"Question Number #11" put"Which change would cause more water to evaporate from a lake?" put"a) A decrease in wind velocity" put"b) A decrease in the strength of sunlight" put"c) An increase in the air temperature" put"d) An increase in the relative humidity." get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #12" put"A cup of water left outside evaporates more slowly when" put"a) The air temperature is high " put"b) The cup has a large exposed surface area" put"c) There is little or no wind" put"d) The air has little water vapor" get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #13" put"Summer days in New York State are likely to be hotter than winter days because in summer" put"a) Earth is closer to the Sun" put"b) The number of sunspots increases" put"c) Earth's northern axis is tilted toward the Sun" put"d) The Sun gives off more energy" get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #14" put"What is a physical reaction?" put"a) A physical reaction is the change in the appearance of a substance in which it can change back to it's original state." put"b) A process in which one or more substances are changed into others" put"c) When a substance becomes 2" put"d) When a substance changes color and then changes is shape and name" get answer
if answer= 'a' then point:=point+1 else
point:=point+0 endif
Please specify what version of Turing you are using
4.0.3
Sponsor Sponsor
Zren
Posted: Fri May 29, 2009 10:23 am Post subject: Re: Need help with adding a timer
I'm guessing your trying to do a Who Wants to be a Millionaire thing. Just make sure you reset the starting time for each question and that the value for Time.Elapsed is in milliseconds.
animeanime
Posted: Fri May 29, 2009 5:53 pm Post subject: RE:Need help with adding a timer
Ok, but I stated this
var startTime: real
var currentTime: real
var timeSinceStart: real
are they soppose to be real?
And It figured out its in milliseconds. I did this
But the output I got was weird. Something like this: 9.289e6
How come I get some letter in between?
tjmoore1993
Posted: Fri May 29, 2009 7:06 pm Post subject: RE:Need help with adding a timer
When a letter is given within a number for example 'e', you should know that you have hit the maximum integer value supported in Turing. Correct me if I am wrong. The best way to stop that is to check your math to see if all is correct. Also setting limits.
By the way I couldn't help you in class today because it would have been cheating.
animeanime
Posted: Fri May 29, 2009 7:09 pm Post subject: Re: Need help with adding a timer
This is what I have, did I do anything wrong?
Turing:
% The multiple choise exam % User choose one of the 4 possiable answers for each question
% The varibles that is declared var mypic :int:=Pic.FileNew("update.bmp") var answer: string var w_mark, point, average: real var startTime, currentTime, timeSinceStart: real var i :int:=0
process playstuff
loop Music.PlayFile("FULL.mp3") endloop end playstuff
fork playstuff
loop
% States what score you start with
point:=0 % Starts the timer
startTime:=Time.Elapsed
% Short descriptiton of the test put"This is a science exam consisting of 20 questions. Please select the most correct answer for each question."
% Test starts with a question put"Question Number #1" put"What is the last planet in the solor system" put"a) Venus" put"b) Neptune" put"c) Mars" put"d) Jupiter" get answer
if answer= 'b' then point:=point+1 else
point:=point+0 endif
put"Question Number #2" put"What is photosynthesis?" put"a) When plants absorb water from the sun" put"b) When plants absorb water from their roots" put"c) When the sun absorbs energy from the plant" put"d) When plants absorbs energy from the sun" get answer
if answer= 'd' then point:=point+1 else
point:=point+0 endif
put"Question Number #3" put"Compared to felsic igneous rocks, mafic igneous rocks contain greater amounts of" put"a) White quartz" put"b) Aluminum" put"c) Pink Feldspar" put"d) Iron " get answer
if answer= 'd' then point:=point+1 else
point:=point+0 endif
put"Question Number #4" put"The Earth's shape most closely resembles which of the following object" put"a) A basketball " put"b) A pear " put"c) A ping-pong ball " put"d) An apple " get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #5" put"The water sphere of the earth is known as the " put"a) Atmosphere" put"b) Troposphere" put"c) Lithosphere" put"d) Hydrosphere" get answer
if answer= 'd' then point:=point+1 else
point:=point+0 endif % After each 5 questions, you get told how many questions you have correctly, and how many incorrectly put" " Pic.Draw(mypic, 0, 15, 0)
w_mark:=5-point
put"You have answered ", point, " questions correctly and ", w_mark, " question incorrectly."
put"Question Number #6" put"Which factor has the greatest influence on the weathering rate of Earth's surface bedrock?" put"a) Local air pressure" put"b) Angle of insolation" put"c) Age of the bedrock" put"d) Regional climate" get answer
if answer= 'd' then point:=point+1 else
point:=point+0 endif
put"Question Number #7" put"What is percipation" put"a) When it is raining" put"b) When the water is absorbed from the clouds" put"c) When air meets water" put"d) Condensation" get answer
if answer= 'a' then point:=point+1 else
point:=point+0 endif
put"Question Number #8" put"What group is the element Potassium in?" put"a) Alkali Metal" put"b) Alkali Earth Metal" put"c) Noble Gas" put"d) Alkali Gas" get answer
if answer= 'a' then point:=point+1 else
point:=point+0 endif
put"Question Number #9" put"What does the symbol H stand for?" put"a) Helium" put"b) Hafnium" put"c) Hydrogen" put"d) Hydrigrrn" get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #10" put"How many elements are there in the Peridoc Table of Elements" put"a) 116" put"b) 120" put"c) 118" put"d) 117" get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif % After each 5 questions, you get told how many questions you have correctly, and how many incorrectly put" " Pic.Draw(mypic, 0, 15, 0)
w_mark:=10-point
put"You have answered ", point, " questions correctly and ", w_mark, " question incorrectly."
put"Question Number #11" put"Which change would cause more water to evaporate from a lake?" put"a) A decrease in wind velocity" put"b) A decrease in the strength of sunlight" put"c) An increase in the air temperature" put"d) An increase in the relative humidity." get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #12" put"A cup of water left outside evaporates more slowly when" put"a) The air temperature is high " put"b) The cup has a large exposed surface area" put"c) There is little or no wind" put"d) The air has little water vapor" get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #13" put"Summer days in New York State are likely to be hotter than winter days because in summer" put"a) Earth is closer to the Sun" put"b) The number of sunspots increases" put"c) Earth's northern axis is tilted toward the Sun" put"d) The Sun gives off more energy" get answer
if answer= 'c' then point:=point+1 else
point:=point+0 endif
put"Question Number #14" put"What is a physical reaction?" put"a) A physical reaction is the change in the appearance of a substance in which it can change back to it's original state." put"b) A process in which one or more substances are changed into others" put"c) When a substance becomes 2" put"d) When a substance changes color and then changes is shape and name" get answer
if answer= 'a' then point:=point+1 else
point:=point+0 endif
put"Question Number #15" put"What is DNA?" put"a) Dexo Nitrogen Acid" put"b) Deoxyribonucleic Acid" put"c) Deoxynythlene Acid" put"d) Dextras Nitrogen Acid" get answer
if answer= 'b' then point:=point+1 else
point:=point+0 endif % After each 5 questions, you get told how many questions you have correctly, and how many incorrectly put" " Pic.Draw(mypic, 0, 15, 0)
w_mark:=15-point
put"You have answered ", point, " questions correctly and ", w_mark, " question incorrectly." put" " put"The last 5 questions are true or false. Please select t or f" put"Question Number #16" put"Ecology is the study of man" put"t) True" put"f) False" get answer
if answer= 'f' then point:=point+1 else
point:=point+0 endif
put"Question Number #17" put"In physics, force is a push or pull that can cause an object with mass to change its velocity." put"t) True" put"f) False" get answer
if answer= 't' then point:=point+1 else
point:=point+0 endif
put"Question Number #18" put"In the Cell theory states that: The cell is not the fundamental unit of life." put"t) True" put"f) False" get answer
if answer= 'f' then point:=point+1 else
point:=point+0 endif
put point
put"Question Number #19" put"A plant cell has a cell wall" put"t) True" put"f) False" get answer
if answer= 't' then point:=point+1 else
point:=point+0 endif
put"This is the last question! It is pretty hard, so take your time!" put"Question Number #20" put"The bond between the organic acid group of one amino acid and the amino group of another amino acid is called a ionic bond" put"t) True" put"f) False" get answer
if answer= 'f' then point:=point+1 else
point:=point+0 endif
% Calclulates how long it took the user to finish the test
currentTime:=Time.Elapsed
timeSinceStart:=(currentTime - startTime)
% Calclulates the average for the test
average:=(point/20)*100
put"Thank you for finishing this test. These are your results" put"Score: ", point, "/20" put"Average: ", average, "%" put"Time: ", timeSinceStart, " milliseconds" if average > 50 thenput"You have passed" else put"You have failed" endif
put"Would you like to take the test again?(y/n)" get answer
exitwhen answer='n' endloop put"Thank you for taking this science test. Have a nice day."
yumrum
Posted: Fri May 29, 2009 7:11 pm Post subject: RE:Need help with adding a timer
u don't need the
else
point := point + 0
animeanime
Posted: Fri May 29, 2009 7:12 pm Post subject: RE:Need help with adding a timer
so if I take that off all of them, it should fix the timer?
tjmoore1993
Posted: Fri May 29, 2009 7:13 pm Post subject: RE:Need help with adding a timer
You did nothing wrong but you should work on efficiency. The teacher doesn't teach efficiency all that greatly...
You should attempt on getting a clean system. I recommend though converting miliseconds to seconds.
Sponsor Sponsor
animeanime
Posted: Fri May 29, 2009 7:14 pm Post subject: RE:Need help with adding a timer