0

Hi everyone, glad to be here...

BTW, this is my first post...

please i need help on this
Write a function that is given a list of students' grades (on a scale from 0 to 100), and returns the number of students who have an A in the class (grade >= 90).

here is my code, it is given me the grades but not the number of students

actually it suppose to be in pseudocode but i did the program in PHP

$list = array(0, 10, 20, 20, 40, 30, 80, 90, 90, 80, 98, 94);
	function searchAgrades($list)	{
		
		for ($i = 0; $i <= count($list); $i++)	{
			if ($list[$i] >= 90)	{
				echo  $list[$i] . " ";
			}
		}
	}
searchAgrades($list);

cheers Yirax

Edited by yirax: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by yirax
0
int numberWhoHaveA = 0
While elements in ArrayOfGrades
    If currentElement.Score >= 90 
        increment numberWhoHaveA
    end If
end While
Output "Number who received an A is " + numberWhoHaveA
0
int numberWhoHaveA = 0
While elements in ArrayOfGrades
    If currentElement.Score >= 90 
        increment numberWhoHaveA
    end If
end While
Output "Number who received an A is " + numberWhoHaveA

thnx a bunch

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.