Beruflich Dokumente
Kultur Dokumente
h>
#include<math.h>
#define MAXSIZE 10
int getChoice();
void getStats(double score[], int n, double *min, double *max, double *avg, double *stDev, double *mode, double
*median);
int choice, i;
double score[MAXSIZE];
do
printf("\n 2. Convert scores to letter gradesand display a table of scores and letter grades. ");
printf("\n 3. Show statistics ( count, maximum, minimum, average, median, mode, standard deviation. ");
printf("\n 6. Exit");
choice = getChoice();
switch (choice)
case 1:
readArray(score, MAXSIZE);
break;
case 2:
showLetterGrades(score, MAXSIZE);
break;
case 3:
showStatistics(score, MAXSIZE);
break;
case 4:
showRanks(score, MAXSIZE);
break;
case 5:
showDistribution(score, MAXSIZE);
default:
printf("\n Wrong Choice. ");
int getChoice()
int choice;
scanf("%d", &choice);
return choice;
int i;
scanf("%lf", &score[i]);
int i;
char grade[n];
printf("\n The score is: %0.1f \t The grade is: %c ", score[i],grade[i]);
int i;
void getStats(double score[], int n, double *min, double *max, double *avg, double *stDev, double *mode, double
*median)
double sum;
sum = score[0];
*min = score[0];
*max = score[0];
*avg = sum / n;
sum = 0.0;
*stDev = sqrt(sum/n);
*mode = 0.0;
maxcount = 0;
int count = 0;
if (score[j] == score[i])
count++;
maxcount = count;
*mode = score[i];
SSort(score, n);
if (n%2==1)
*median = score[n/2];
else
*median = score[(n-1)/2];
int i, j, min, t;
min = i;
min = j;
t = score[i];
score[i] = score[min];
score[min] = t;
int ranks[n], i;
int i;
SSort(score, n);
ranks[i]=i+1;
int i, k=5;
char LG[5]={'A','B','C','D','F'};
char grade[n];
double distribution[n];
getDistributions(grade, n, distribution,k);
int i, count[k];
count[i]=0;
if (grade[i]=='A') count[0]++;
if (grade[i]=='B') count[1]++;
if (grade[i]=='C') count[2]++;
if (grade[i]=='D') count[3]++;
if (grade[i]=='F') count[4]++;
distribution[i]= count[i]/(double)n*100;