## 381 - Making the Grade

Moderator: Board moderators

rico
New poster
Posts: 1
Joined: Tue Nov 06, 2001 2:00 am
there is some prob with the example

at the third row in the example.
60 20 70 5 3 65.0 71.0 B B
since the student got 5 bonus points
adjusted avg point would be 65.0*1.03=66.95 ->67.0 (rounded to the nearest tenth)which is not 71.0 ( increased 9% .. not just 3% )
could somebody tell me why?
am i taking the situation wrong?

<font size=-1>[ This Message was edited by: rico on 2001-11-06 09:23 ]</font>

Even
Learning poster
Posts: 75
Joined: Thu Nov 22, 2001 2:00 am
Location: Taiwan
mm.. about bonus ...it means ...

every 2 bonus points will plus average 3

that is ...

Bns| 1 2 3 4 5 6 7 ....etc.
Adj| 0 3 3 6 6 9 9 ....etc.

so .... Avg 65 with Bns points 5...

will get AdjAvg = 65 + 6 = 71 ...

<font size=-1>[ This Message was edited by: Even on 2001-11-22 14:14 ]</font>

joshila21
New poster
Posts: 5
Joined: Fri May 07, 2004 12:15 am
Contact:

### 381-Why WA?

i dont understand what's wrong with my code?
can any one help me plaese?

here is the code:

#include <stdio.h>
#include <math.h>

struct {
int Bns;
int Abst;
int Test[10];
float Avg;
}student[31];

int bon[200];

void main (void)
{
int s,t,i,j,k,n,min,sum,decrease,po=-3;
float SUM,MEAN,SD,BELOW,avg_gpa;
for(i=0;i<200;i++)
{
if(!(i%2))po+=3;
bon=po;
}
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&s);
scanf("%d",&t);
for(j=0;j<s;j++)
{
for(k=0;k<t;k++)
scanf("%d",&student[j].Test[k]);
scanf("%d",&student[j].Bns);
scanf("%d",&student[j].Abst);
}
if(t>2)
{
for(j=0;j<s;j++)
{
min=0;
for(k=1;k<t;k++)
if(student[j].Test[k]<student[j].Test[min])
min=k;
student[j].Test[min]=0;
}
}
for(j=0;j<s;j++)
{
sum=0;
for(k=0;k<t;k++)
sum=sum+student[j].Test[k];
if(t>2)student[j].Avg=sum/(t-1);
else student[j].Avg=sum/t;
}
SUM=0;
for(j=0;j<s;j++)
SUM=SUM+student[j].Avg;
MEAN=SUM/s;
SUM=0;
for(j=0;j<s;j++)
SUM=SUM+(student[j].Avg-MEAN)*(student[j].Avg-MEAN);
SUM=SUM/s;
SD=sqrt(SUM);
if(SD<1)SD=1;
SUM=SD+MEAN;
BELOW=MEAN-SD;
for(j=0;j<s;j++)
{

decrease=student[j].Abst/4;
for(k=0;k<decrease;k++)
{
}
if(!student[j].Abst)
{
}
}
avg_gpa=0;
for(j=0;j<s;j++)
{
case 'A':avg_gpa=avg_gpa+4;break;
case 'B':avg_gpa=avg_gpa+3;break;
case 'C':avg_gpa=avg_gpa+2;break;
case 'D':avg_gpa=avg_gpa+1;break;
case 'F':avg_gpa=avg_gpa+0;break;
}
}
avg_gpa=avg_gpa/s;
printf("%0.1f\n",avg_gpa);
for(j=0;j<s;j++)
{
for(k=0;k<t;k++)
student[j].Test[k]=0;
student[j].Bns=0;
student[j].Abst=0;
student[j].Avg=0;
}
}
printf("END OF OUTPUT");
}
be a good man

linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

### Plz help me! 381.

I've got the error! I made a simple mistake. Now I've got AC. Actually the problem isn't so hard!
Thanks everyone.
Last edited by linux on Thu Sep 11, 2008 9:20 pm, edited 1 time in total.
Solving for fun..

Oronno
New poster
Posts: 21
Joined: Sun Jul 09, 2006 1:42 pm
Location: Dhaka
Contact:

### Why Presentation Error???

I have solve this problem and it show correct output, (also in correct format). But i can't understand why ACM show me Presentation Error.
I can't understand why?
I think it is not my fault, it is ACM's fault

Code: Select all

``````//***************** 381: Making the Grade

Code has removed
``````
Last edited by Oronno on Sat Dec 23, 2006 7:13 pm, edited 1 time in total.
I like programming but i am so lazy to do it...

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
Use

Code: Select all

``printf("\nEND OF OUTPUT\n");``
And dont forget to remove your code.
Ami ekhono shopno dekhi...
HomePage

newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Contact:

### 381 - Making the Grade

Code: Select all

`` the code is removed after AC``

simply the best!
Last edited by newton on Wed Jan 31, 2007 7:17 am, edited 1 time in total.

Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:
newton that a childish request

you can use structure to solve this problem.
its help full for debuging

Akash chhoyar swopno
Dream to touch the sky

mice123456789
New poster
Posts: 12
Joined: Tue Aug 27, 2002 6:09 pm

### Re: 381 Making the Grade

Can someone give me sample input/output for this problem? Thanks in advance

amishera
New poster
Posts: 38
Joined: Sat Dec 27, 2008 10:42 pm

### Re: 381 Making the Grade

Code: Select all

``````#include <stdio.h>
#include <math.h>
#include <stdlib.h>

typedef struct studentRecord
{
int scores[11];
int nAbsent;
int nBonus;
double avgScore;
};

double roundToTenth(double d)
{
char ss[30];
sprintf(ss,"%.1lf",d);
return atof(ss);
}

int main()
{
studentRecord r[31];

int i,j,k,n,t,s;

scanf("%d",&n);

for (i = 0;i < n;i++)
{
double classSum = 0;

scanf("%d %d",&s,&t);

int tt = t;

if (t > 2)
t--;

for (j = 0;j < s;j++)
{
scanf("%d",&r[j].scores[0]);

int min = r[j].scores[0];

double sum = min;

for (k = 1;k < tt;k++)
{
scanf("%d",&r[j].scores[k]);
sum += r[j].scores[k];
if (r[j].scores[k] < min)
{
min = r[j].scores[k];
}
sum = roundToTenth(sum);
}

if (tt > 2)
{
sum -= min;
}

r[j].avgScore = roundToTenth(sum/t);

classSum += r[j].avgScore;

scanf("%d %d",&r[j].nBonus,&r[j].nAbsent);
}

double classAvg = roundToTenth(classSum/s);

double sqrSum = 0;

for (j = 0;j < s;j++)
{
double diff = r[j].avgScore-classAvg;
double sqrTerm = diff*diff;
sqrSum += sqrTerm;
}

double classSd = roundToTenth(sqrt(sqrSum/s));
if (classSd < 1)
classSd = 1;

int sumLetter = 0;

for (j = 0;j < s;j++)
{
int bonusTimes = r[j].nBonus/2;
double temp = r[j].avgScore+3*bonusTimes;

//			printf("%lf %lf %d\n",classAvg,classSd,bonusTimes);
int letter;

if (temp >= classAvg+classSd)
{
letter = 4;
}
else if (classAvg <= temp &&  temp < classAvg+classSd)
{

letter = 3;
}
else if (temp < classAvg && temp >= classAvg-classSd)
{

letter = 2;
}
else if (temp < classAvg-classSd)
{

letter = 1;
}

if (r[j].nAbsent > 0)
letter -= r[j].nAbsent/4;
else if (r[j].nAbsent == 0)
letter++;

if (letter < 0)
letter = 0;
else if (letter > 4)
letter = 4;

sumLetter += letter;
}