Question

Project Exam Statistics A CIS 22A class has two midterm exams with a score between 0 and 100 each. Fractional scores, such asScreen Output: Display a welcome message and the purpose of the program, including the names of the input and output files. D

have to create five different functions above and call it in the main fucntion.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//since you are not mentioned if it's c/c++ , doing it in C , so that it can be run in c++ too

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 10
void printInfo();
int getStuData(char ids[][10], int scores[][2]);
float *calcAvg(char ids[][10], int n);
void writeStuData(char ids[][10], int scores[][2], int n);
void printEnd();

int main()
{
   int n;
   int ids[SIZE], scores[SIZE][2];
   //function calls
   printInfo();
   n = getStuData(ids, scores);
   writeStuData(ids, scores,n);
   printEnd();
}
void printInfo()
{
   printf("####Welcome #####\n");
   printf("Name: Your Name\n");
   printf("Input file: studentIn.txt\n");
   printf("Output: studentOut.txt\n");
   printf("Description: \n*This program reads the student id and two scores from input file.\n*It then calculates average for each student and as well class average and writes to output file.\n");
}
int getStuData(char ids[][10], int scores[][2])
{
   FILE *fp;
   int count = 0, score1, score2;
   char id[10];

   fp = fopen("studentIn.txt", "r");
   if (fp == NULL)
   {
       printf("Not able to open file studentIn.txt for reading\n");
       return -1;
   }
   while (!feof(fp))
   {
       fscanf(fp, "%s%d%d", &id, &score1, &score2);
       strcpy(ids[count] ,id);
       scores[count][0] = score1;
       scores[count][1] = score2;
       ++count;
   }
   return count;
}
float *calcAvg(int scores[][2], int n)
{
   float *avg=(float*)malloc(n*sizeof(float));
   float sum = 0;
   int i,j;
   for (i = 0; i < n; i++)
   {
       avg[i] = 0;
   }
   for (i = 0; i < n; i++)
   {
       for (j = 0; j < 2; j++)
       {
           sum+= scores[i][j];
       }
       avg[i] = sum / 2;
       sum = 0;
   }
   return avg;
}
void writeStuData(char ids[][10], int scores[][2], int n)
{
   int i;
   FILE *fp;

   float *avg = calcAvg(scores, n);
   //open file for writing
   fp = fopen("studentOut.txt", "w");
   if (fp == NULL)
   {
       printf("Not able to open file studentOut.txt for writing\n");
       return;
   }
   fprintf(fp, "=============================\n");
   fprintf(fp, " CSA 22A\nMidterm Exams Statistics\n=============================\n");
   fprintf(fp, " ID\tExam1\tExam2\tAverage\n");

   for (i = 0; i < n; i++)
   {
       fprintf(fp, "%5s\t%3d\t%3d\t%.1f\n", ids[i], scores[i][0], scores[i][1], avg[i]);
   }
   fprintf(fp, "=============================\n");
   fprintf(fp, "Number of students: %d ",n);
   fclose(fp);
}
void printEnd()
{
   printf("\nExit Message: Bye bye...\n");
}

===========================

//Output screenshot given along with studentIn.txt and studentOut.txt(input and output file respectively)

Add a comment
Know the answer?
Add Answer to:
have to create five different functions above and call it in the main fucntion. Project Exam...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes...

    CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes the user and displays the purpose of the program. It then prompts the user to enter the name of an input file (such as scores.txt). Assume the file contains the scores of the final exams; each score is preceded by a 5 characters student id. Create the input file: copy and paste the following data into a new text file named scores.txt DH232 89...

  • Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and...

    Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and use a 2D array Student will demonstrate the ability to create and use a jagged array Student will demonstrate the ability to design a menu system Student will demonstrate the ability to think Program Specifications: Write a program that does the following: Uses a menu system Creates an array with less than 25 rows and greater than 5 rows and an unknown number of...

  • import java.util.*; /** Description: This program determines the average of a list of (nonnegative) exam scores....

    import java.util.*; /** Description: This program determines the average of a list of (nonnegative) exam scores. Repeats for more exams until the user says to stop. Input: Numbers, sum, answer Output: Displays program description Displays instruction for user Displays average Algorithm: 1. START 2. Declare variables sum, numberOf Students, nextNumber, answer 3. Display welcome message and program description 4. DOWHILE user wants to continue 5. Display instructions on how to use the program 6. Inititalize sum and number of student...

  • Language: C++ Write a program that will allow the instructor to enter the student's names, student...

    Language: C++ Write a program that will allow the instructor to enter the student's names, student ID, and their scores on the various exams and projects. A class has a number of students during a semester. Those students take 4 quizzes, one midterm, and one final project. All quizzes weights add up to 40% of the overall grade. The midterm exam is 25% while the final project 35%. The program will issue a report. The report will show individual grades...

  • use  JOptionPane to display output Can someone please help write a program in Java using loops, not...

    use  JOptionPane to display output Can someone please help write a program in Java using loops, not HashMap Test 1 Grades After the class complete the first exam, I saved all of the grades in a text file called test1.txt. Your job is to do some analysis on the grades for me. Input: There will not be any input for this program. This is called a batch program because there will be no user interaction other than to run the program....

  • C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you...

    C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you can. Level 1: (20 points) Write FUNCTIONS for each of the following: a) Validate #students, #scores. b) Compute letter grade based on average. c) Display student letter grade. d) Display course average. Level 2: (15 points) Use ARRAYS for each of the following. e) Read a student's scores into array. f) Calculate the student's average based on scores in array. g) Display the student's...

  • 2. In a file called passfail.py, write a Python program to solve the following problem: Given...

    2. In a file called passfail.py, write a Python program to solve the following problem: Given a file students.txt with the following information for a stu dent: student number, average quiz mark, average assignment mark, midterm exam mark, and final exam mark (where each mark is recorded out of 100), de termine if the student has passed or failed based on the following information A student will pass the course if they have a passing mark (50% or higher) for...

  • python question 2. In a file called passfail.py, write a Python program to solve the following...

    python question 2. In a file called passfail.py, write a Python program to solve the following problem: Given a file students.txt with the following information for a stu dent: student number, average quiz mark, average assignment mark, midterm exam mark, and final exam mark (where each mark is recorded out of 100), de termine if the student has passed or failed based on the following information: • A student will pass the course if they have a passing mark (50%...

  • Must be done in C# please! Thanks! In this assignment you will create a program named...

    Must be done in C# please! Thanks! In this assignment you will create a program named Test Scores that displays the average of all tests; average midterm score; average final score; and displays the midterm or final score of a particular student. Create a class level two dimensional integer array named Grades initialized with the following data: 897 242 301 987 116 450 865 128 992 109 88 75 94 70 90 87 81 79 97 79 78 80 92...

  • c++ implement a student class Determine the final scores, letter grades, and rankings of all students...

    c++ implement a student class Determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name, id, five quiz scores, two exam scores, and one final exam score. For this project, you will develop a program named cpp to determine the final scores, letter grades, and rankings of all students in a course. All...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT