Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

How can I modify below code to allow the user to enter a weight for each grade in addition to entering number of students, name of student and amount of exams?

How can I modify below code to allow the user to enter a weight for

each grade in addition to entering number of students, name of student and amount of exams?

// C code
// This program will calculate the average of an undefined number
// of exams for an undefined number of students.
// Developer: F. Smith
// Date: June 24, 2020
#include <stdio.h>

int main(void) {
// variable declarations:
char name [100];
float sum, grade, average;
int students, grades, exams, studentquantity;

// Prompt user to input number of students
printf(“Please enter number of students: \n”);
scanf(“%d”, &studentquantity);

// loop through students
for (students = 0; students < studentquantity; students++) {

// Prompt user to input number of grades to process
printf(“Please enter number of grades for student (%d): “,(students+1));
scanf(“%d”, &grades);
sum = 0;
printf(“Enter Student name: “);
scanf (“%s”, name);
for (exams = 0; exams < grades; exams++) {
// float uses %f, double uses %lf
printf(“Enter grade %d: “,(exams+1));
scanf (“%f”, &grade);
sum = sum + grade;

} // end for each exam
average = sum / grades;
printf (“Average for %s is %.2f\n”, name, average);
printf(“\n\n”);
} // end for each student
printf(“… Bye …\n”);

return 0;
} // end main

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"