All pastes #165885 Raw Edit

Rave Hanker

public text v1 · immutable
·published 2006-09-10 09:02 UTC
rendered paste body
Problem Statement

Dr.Maheshwaran is the head of a professional exam coaching center. Wishing to target the weaker students for extra coaching ,he has acquired a list of the math and verbal test scores from all the children in the center.

As Dr.Maheshwaran, your job is to Write a method belowAvg that takes two int[], math and verbal, representing the math and verbal scores of all of the children in the center, and returning the number of students whose composite total(sum of both subjects) is below the average composite total of all students in the center.

Here math[i] and verbal[i] represents the math and verbal score of the (i+1)th student.

Notes

1. Each element of math corresponds to the element with the same index in verbal.
2. The number of children is the length of math and verbal.
3. math and verbal will contain the same number of elements.
4. math will contain between 1 and 50 elements, inclusive.
5. each value in math and in verbal is between 200 and 800, inclusive.
Program Format

For C++ :

int belowAvg(vector <int> math, vector <int> verbal)
{
	...
	return a;
}


For Java :

public class prog
{
	public int belowAvg(int[] math, int[] verbal)
	{
		...
		return a;
	}
}


Examples

0)
    
{200,250,700,700}
{400,400,400,400}

Returns: 2
The composite scores of the 4 children are 600, 650, 
1100, and 1100 and the average composite score is 862.5,
so 2 of the children are below average.



1)
    
{500,400}
{300,400}

Returns: 0
Both children have the same composite score 800 which 
is also the average. Neither are below average



2)
    
{293}
{799}

Returns: 0



3)
    
{400,400,400,400,400,400,401}
{400,400,400,400,400,400,400}

Returns: 6
The average composite score is just above 800, 
so 6 of the 7 children are below average.