
-----------------------------------
5pretty
Tue Apr 29, 2014 3:04 pm

Help with modifying the program turing
-----------------------------------
What is it you are trying to achieve?
Modify the mark analysis program to count the number of passing and failing marks proceesed please help me


What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

var students : int
var passinggrade : int
var finalgrade: int
var counter: int

for i: 1..10 by 1
end for
counter := 1    %Initialize

    put "Input the number of students :"..
    get students
    
loop
    put "Enter the passing code for a course: "
    get passinggrade
    put "Enter mark for student: ", counter
    get finalgrade
    if finalgrade >= passinggrade then
        put "Student passes"
        put ""
     else
        put "Student fails"
        put ""
     end if
     exit when counter >= students    %Test
     counter := counter + 1    %Update
     
end loop

Please specify what version of Turing you are using


-----------------------------------
Insectoid
Tue Apr 29, 2014 3:34 pm

RE:Help with modifying the program turing
-----------------------------------
Have you tried anything?

-----------------------------------
5pretty
Tue Apr 29, 2014 3:43 pm

Re: Help with modifying the program turing
-----------------------------------
I am trying this accumaltor thing but its not working. I do not know what to put like if we need a counter or variable

-----------------------------------
Tony
Tue Apr 29, 2014 4:17 pm

Re: Help with modifying the program turing
-----------------------------------
I do not know what to put like if we need a counter or variable
Forget about computers for a moment -- how would you handle the task? If you were physically handed a stack of papers with grades, what steps would you use to accomplish the same task?

-----------------------------------
5pretty
Tue Apr 29, 2014 4:34 pm

Re: Help with modifying the program turing
-----------------------------------
I would keep the passed marks on one side and the failed ones on the other.

-----------------------------------
Tony
Tue Apr 29, 2014 5:39 pm

RE:Help with modifying the program turing
-----------------------------------
That's a start, but it gives you two piles, and not the "count". What else would you do?

-----------------------------------
5pretty
Tue Apr 29, 2014 6:15 pm

Re: Help with modifying the program turing
-----------------------------------
tally the students who have passed and failed on a piece of paper

-----------------------------------
Tony
Tue Apr 29, 2014 7:02 pm

RE:Help with modifying the program turing
-----------------------------------
That is a good approach.

In this case, a "piece of paper" is a place where you record/remember information -- similar to variables.

"Tally" would be the process of incrementing a value in a variable.

You can take the ideas that you came up with, and try to describe them in Turing's language.


var passing_students : int := 0 % keep track of passing students; initially none

..
passing_students := passing_students + 1 % tally one more passing student


-----------------------------------
5pretty
Tue Apr 29, 2014 7:09 pm

Re: Help with modifying the program turing
-----------------------------------
var students : int 
var passinggrade : int 
var finalgrade: int 
var counter: int 
var passing_students : int := 0 % keep track of passing students; initially none 
var failing_students : int := 0 % keep track of failing students; intiitally none

for i: 1..10 by 1 
end for 
counter := 1 %Initialize 

put "Input the number of students :".. 
get students 

loop 
put "Enter the passing code for a course: " 
get passinggrade 
put "Enter mark for student: ", counter 
get finalgrade 
if finalgrade >= passinggrade then 
put "Student passes" 
put "" 
else 
put "Student fails" 
put "" 
end if 
exit when counter >= students %Test 
counter := counter + 1 %Update 
passing_students := passing_students + 1
failing_students := passing_students + 1
end loop

-----------------------------------
Tony
Tue Apr 29, 2014 10:35 pm

RE:Help with modifying the program turing
-----------------------------------
You've got the right pieces, but not in the right order. How would you follow those instructions?


if finalgrade >= passinggrade then % if 
put "Student passes" % say "Student passes"
else % otherwise
put "Student fails" % say "Student fails" 
end if

exit when counter >= students % stop doing anything after N times

counter := counter + 1 % keep track of how many times the above was done

passing_students := passing_students + 1 % tally 1 for passing students
% and also
failing_students := passing_students + 1 % tally 1 for failing students


You might notice that in such a setup both tallies will always be the same.

-----------------------------------
5pretty
Wed Apr 30, 2014 7:42 am

Re: Help with modifying the program turing
-----------------------------------
so we will need variables for passing_grade and failing_grade
