Question

Write a C program that allows a user to enter up to 30 student id’s and...

Write a C program that allows a user to enter up to 30 student id’s and 3 grades per student. It will then compute and display a report of the students averages, and then a statement of the class average for those grades. The following is a sample run that demonstrates what your program should look like:

Please enter your school name: Cape Tech

Welcome to the Cape Tech Grade Calculator

Enter the number of students to process (0 - 30): 33

*** Invalid number of students entered. ***

Enter the number of students to process (0 - 30): 3

Enter the ID Number for student #1(0-9999): 1234

Now enter the 3 grades to be averaged. Enter grade #1: 77

Enter grade #2: 88 Enter grade #3: 99

Enter the ID Number for student #2(0-9999): 23456

Bad ID Number, please re-enter Enter the ID

Number for student #2(0-9999): 3456

Now enter the 3 grades to be averaged.

Enter grade #1: 55 Enter grade #2: 777

*** Invalid entry. Grade must be from 0 to 100. ***

Enter grade #2: 77

Enter grade #3: 62

Enter the ID Number for student #3(0-9999): 034

Now enter the 3 grades to be averaged.

Enter grade #1: 44

Enter grade #2: 77

Enter grade #3: 98

Grade Report for Cape Tech ID No. Avg.

Grade 1234 88 B+ 3456 65 D 0034 73 C

The class average of the 3 students is 75. This program needs to use arrays ad these variables:

int number_of_students; /* user decides number of students */

int grade1, grade2, grade3; /* holds 3 integer grades */

int id[30]={0}; /* holds up to 30 integer student ids */

int average[30]; /* will contain the averages rounded off */

char my_name[20] = "CCCC"; /* array of up to 20 characters for school*/

int class_total = 0; /* accumulator int class_average; /* will contain the averages rounded off */

int x; /* loop control variable */

int sum = 0; /* initialize sum to zero.*/

char c; /* for buffer clearing *

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

Program

#include<stdio.h>
int main()
{
   int number_of_students; /* user decides number of students */
   int grade1, grade2, grade3; /* holds 3 integer grades */
   int id[30]={0}; /* holds up to 30 integer student ids */
   int average[30]; /* will contain the averages rounded off */
   char my_name[20] = "CCCC"; /* array of up to 20 characters for school*/
   int class_total = 0; /* accumulator */
   int class_average; /* will contain the averages rounded off */
   int x; /* loop control variable */
   int sum = 0; /* initialize sum to zero.*/
   char c; /* for buffer clearing */
   char grade[30];

   printf("Please enter your school name:");
   gets(my_name);
   printf("Welcome to the %s Grade Calculator",my_name);
   printf("\nEnter the number of students to process (0 - 30):");
   scanf("%d",&number_of_students);
   while(number_of_students<0||number_of_students>30)
   {
   printf("\n*** Invalid number of students entered. ***");
   printf("\nEnter the number of students to process (0 - 30):");
   scanf("%d",&number_of_students);
  
   }
   for(x=0;x<number_of_students;x++)
   {
   printf("Enter the ID Number for student #%d(0-9999):",(x+1));
   scanf("%d",&id[x]);
   while(id[x]<0||id[x]>9999)
   {
   printf("\nBad ID Number, please re-enter ID");
   printf("\nEnter the ID Number for student #%d(0-9999):",(x+1));
   scanf("%d",&id[x]);
   }
   printf("Now enter the 3 grades to be averaged.");
   printf("\nEnter grade #1: ");
   scanf("%d",&grade1);
   while(grade1<0||grade1>100)
   {
   printf("\n*** Invalid entry. Grade must be from 0 to 100. ***");
   printf("\nEnter grade #1: ");
   scanf("%d",&grade1);
   }
   printf("Enter grade #2: ");
   scanf("%d",&grade2);
   while(grade2<0||grade2>100)
   {
   printf("\n*** Invalid entry. Grade must be from 0 to 100. ***");
   printf("\nEnter grade #2: ");
   scanf("%d",&grade2);
   }
   printf("Enter grade #3: ");
   scanf("%d",&grade3);
   while(grade3<0||grade3>100)
   {
   printf("\n*** Invalid entry. Grade must be from 0 to 100. ***");
   printf("\nEnter grade #3: ");
   scanf("%d",&grade3);
   }
   sum=grade1+grade2+grade3;
   average[x]=sum/3;
   class_total+=sum;
   if (average[x]>=90)
        {  
            grade[x]='A';
         
        }
        else if (average[x]>=80)
        {
            grade[x]='B';
          
        }
        else if (average[x]>=70)
        {
            grade[x]='C';
          
        }
        else if (average[x]>=60)
        {
            grade[x]='D';
          
        }
        else
        {
            grade[x]='F';
          
        }
   }
   printf("Grade Report for %s ",my_name);
   printf("\nIDNo. \tAvg.\tGrade\n");
   for(x=0;x<number_of_students;x++)
   {
   printf("%d\t%d\t%c\n",id[x],average[x],grade[x]);
   }
   class_average=class_total/(number_of_students*3);
   printf("\nThe class average of the %d students is %d\n",number_of_students,class_average);
   return 0;
}

Output

Please enter your school name:Cape Tech
Welcome to the Cape Tech Grade Calculator
Enter the number of students to process (0 - 30):33

*** Invalid number of students entered. ***
Enter the number of students to process (0 - 30):3
Enter the ID Number for student #1(0-9999):1234
Now enter the 3 grades to be averaged.
Enter grade #1: 77
Enter grade #2: 88
Enter grade #3: 99
Enter the ID Number for student #2(0-9999):23456

Bad ID Number, please re-enter ID
Enter the ID Number for student #2(0-9999):3456
Now enter the 3 grades to be averaged.
Enter grade #1: 55
Enter grade #2: 777

*** Invalid entry. Grade must be from 0 to 100. ***
Enter grade #2: 77
Enter grade #3: 62
Enter the ID Number for student #3(0-9999):034
Now enter the 3 grades to be averaged.
Enter grade #1: 44
Enter grade #2: 77
Enter grade #3: 98


Grade Report for Cape Tech


IDNo.    Avg.   Grade
1234   88   B
3456   64   D
34   73   C

The class average of the 3 students is 75

Add a comment
Know the answer?
Add Answer to:
Write a C program that allows a user to enter up to 30 student id’s and...
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
  • Write a program that asks the user for a student name and asks for grades until...

    Write a program that asks the user for a student name and asks for grades until the user enters a non-number input, it should then ask if the user wants to enter another student, and keep doing the process until the user stops adding students. The student’s must be stored in a dictionary with their names as the keys and grades in a list. The program should then iterate over the dictionary elements producing the min, max, and mean of...

  • 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...

  • please use the c language Assignment 12 The program to write in this assignment is a...

    please use the c language Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 scores 201 1710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student id...

  • in C porgraming . use #include〈stdio.h〉 #include〈stdlib.h〉 Assignment 12 The program to write in this assignment...

    in C porgraming . use #include〈stdio.h〉 #include〈stdlib.h〉 Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and scores are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 2011710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student_id,...

  • For C++ program Your program should first prompt the user for the number of students they...

    For C++ program Your program should first prompt the user for the number of students they wish to enter. For each student, the user will be prompted to enter the student’s name, how many tests the student has taken, and the grade for each test. Each test’s grade will be inputted as a number representing the grade for that test. Once each student’s information has been entered, the program will display the number of students. Additionally, each student will have...

  • using C# Write a program which calculates student grades for multiple assignments as well as the...

    using C# Write a program which calculates student grades for multiple assignments as well as the per-assignment average. The user should first input the total number of assignments. Then, the user should enter the name of a student as well as a grade for each assignment. After entering the student the user should be asked to enter "Y" if there are more students to enter or "N" if there is not ("N" by default). The user should be able to...

  • In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student...

    In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student information system. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow student to edit ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • Please help me with this program.You are to write a C++ program that will read in...

    Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...

  • In C++, write a complete program that receives a series of student records from the keyboard...

    In C++, write a complete program that receives a series of student records from the keyboard and stores them in three parallel arrays named studentID and courseNumber and grade. All arrays are to be 100 elements. The studentID array is to be of type int and the courseNumber and grade arrays are to be of type string. The program should prompt for the number of records to be entered and then receive user input on how many records are to...

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