Stuck newbie! Array problems
Author Message
Stuck newbie! Array problems

Sorry for the simpleton question but I'm very new at this.
I've been working my way through some questions on arrays but have got stuck
at this one:

Read in a number n followed by n exam marks. Output the highest possible
mark which would allow 75% of the students to pass.

Using procedures, I can read in the values and put them into an array. I can
sort them into ascending order no problem. I just can't get my dumb head
round how to get the highest mark which will allow 75% to pass?

I'm not asking for a complete solution, but can someone just point me in the
right direction, a clue possibly in very simple language.

John.

Wed, 18 Jun 1902 08:00:00 GMT
Stuck newbie! Array problems
Hi John,

Let's see if i understood your problem:

1)
Use an array of record
VAR
ary=array[1..n] of record
studs:integer;
exam:integer;
end;

2)
Fill the array and sort the entrys by ascending oder
of the exam-value.
(Let 8 be the highest exam mark in this example)
May be it will then look as follows:

[1] studs:10   exam:1
[2] studs:7     exam:2
[3] studs:33  exam:3
[4] studs:64 exam:4
...
[n] studs:12 exam:8

3)
now count all the studs
compute the number of studs, that will make 75% of
the total number of students. in this exmaple let this be 103

4)
now start counting the studs from the array-entry[1] up
to entry[n] UNTIL you reach this 103 (=75%)

5)
the exam-field in the last entry you counted then holds
the desires value.

You may also use 2 array like
studs:array[1..n] of integer;
exam:array[1..n] of integer;
The you will have to sort both arys, of course.

Did i understood your question ?

JOE :-))

Wed, 18 Jun 1902 08:00:00 GMT
Stuck newbie! Array problems

Quote:

> Using procedures, I can read in the values and put them into an array. I can
> sort them into ascending order no problem. I just can't get my dumb head
> round how to get the highest mark which will allow 75% to pass?

This is maybe a long way round, but it ought to work.

1. Find 75% of the number of students and call it 'x'.

2. Loop 'm' from 0 to 100 (being the percentage mark) and figure out
what percentage of students pass at that mark 'm'. Clearly it will
start off high (ie, n out of n passes for a m=0% pass mark) but
will fall towards 'x'.

3. When it reaches 'x', stop. The value of the loop variable 'm' will
be the required pass mark for 75% of the students to get through.

Mike{*filter*}son, Black Cat Software Factory, Edinburgh, Scotland
fax 0131-271-1551 - Columnated Ruins Domino - Mellotron M400 #996

Wed, 18 Jun 1902 08:00:00 GMT
Stuck newbie! Array problems

: Read in a number n followed by n exam marks. Output the highest possible
: mark which would allow 75% of the students to pass.

So there are n students. You want to make sure no more than (n div
4) fail. Is that enough of a direction?

Robert

Wed, 18 Jun 1902 08:00:00 GMT
Stuck newbie! Array problems

Quote:
>Using procedures, I can read in the values and put them into an array. I
can
>sort them into ascending order no problem. I just can't get my dumb head
>round how to get the highest mark which will allow 75% to pass?

As I understand it, you want a 'pass mark' so that 75% of the class passes.
If this is what you want and you already have the array sorted in assending
order, then the pass mark is just MarksArray[n div 4].

Wed, 18 Jun 1902 08:00:00 GMT
Stuck newbie! Array problems

Quote:

>Using procedures, I can read in the values and put them into an array. I can
>sort them into ascending order no problem. I just can't get my dumb head
>round how to get the highest mark which will allow 75% to pass?

You'll know how many students you've done marks for while you read in the
values. Therefore you can find 25% of the number of students. Think about which
way to round the fraction if you don't have a number cleanly divisble by 4.

As you already have them in order, you can read Student 25%'s mark. That'll give
you the mark needed to pass 75%.

Quote:
>I'm not asking for a complete solution, but can someone just point me in the
>right direction, a clue possibly in very simple language.

Good for you, too many posters here want their homework done for them.

Hope the above helps, I know it's easy to miss a single paintstroke when you're
looking at the big picture :-)

--
Pedt

Wed, 18 Jun 1902 08:00:00 GMT

 Page 1 of 1 [ 6 post ]

Relevant Pages