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.

Many thanks in advance
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  
 
 [ 6 post ] 

 Relevant Pages 

1. How to initialise database, Newbie stuck

2. newbie array question

3. Newbie question on pointers to arrays

4. Please help with this problem!!ARRAY problem

5. Newbie wants newbie friend

6. newbie Problem with indexbuilding dBasefiles

7. How to create table - Newbie problem

8. Newbie, FP installation problem

9. Slight problem for a Pascal newbie

10. Delphi3 and Oracle8 connection-problems, newbie-question

11. newbie install problem.

12. Weird newbie problem

 

 
Powered by phpBB® Forum Software