I need help in solving this programming problem. Thank you! //  ********************* MODIFY ME!!! ********************* #include #include #include "lab4_ex1.h" // Removes or cleans the dangling 'new line' character in stdin // @param void // @return none void flush() {     char c;     while ((c = getchar()) != '\n' && c != EOF); } // Creates the course (one course only) by asking the for user input // @param num course number, e.g. 1,2,3 // @return course Course createCourse(int num) {     Course course;     //input code here     return course; } // Displays the course  // @param course number, e.g. 1, 2, 3 // @return none void displayCourse(Course course) {     printf("course name: %s\n", course.name);     printf("course grade: %0.2f\n", course.grade);     printf("course units: %d\n", course.unit); } // Computes the GPA from three courses, based on the formula in README.md  // @param courses[TOTAL_COURSE]  // @return GPA float computeGPA(Course courses[TOTAL_COURSE]) {     //  ********************* YOUR CODE HERE *********************     return 0.0f; } // Creates the student by asking for user input  // @param none // @return student structure with id, name, degree, courses, and GPA Student createStudent() {     Student student;          // input code here          return student; } // Displays the student  // @param student struct // @return none void displayStudent(Student student) {     printf("student name: %s\n", student.name);     printf("ID number: %d\n", student.id);     printf("degree: %s\n", student.degree);     for (int i = 0; i < TOTAL_COURSE; i++)     {         displayCourse(student.courses[i]);     } } // Displays the student with GPA // @param student struct // @return none void displayStudentGPA(Student student) {     printf("%s with ID number %d has a GPA of %.3f\n", student.name, student.id, student.GPA); }   this is the header file //  ********************* MODIFY ME!!! ********************* #ifndef lab4_ex1_h #define lab4_ex1_h #define TOTAL_COURSE 3 #define BUFFER_SIZE 80 typedef struct Course{     char name[BUFFER_SIZE];     int unit;     float grade; } Course; typedef struct Student{     int id;     char name[BUFFER_SIZE];     char degree[BUFFER_SIZE];     Course courses[TOTAL_COURSE];     float GPA; } Student; Student createStudent(); Course createCourse(int); void displayStudent(Student); void displayStudentGPA(Student student); void displayCourse(Course); float computeGPA(Course courses[TOTAL_COURSE]); void flush(); #endif   this is the main.cpp file #include  // needed by printf, scanf #include // needed by malloc #include "lab4_ex1.h" int main(void) {     int N;     // Get the number of students N     do     {         printf("Enter number of students to record: ");          scanf("%d", &N);     } while (N < 1);     flush();     // Allocate memory to the data of students     Student *record = (Student *)malloc(N * sizeof(Student));     // Create student record/s     for (int i = 0; i < N; i++)         record[i] = createStudent();     // Display GPA for all student records     for (int i = 0; i < N; i++)         displayStudentGPA(record[i]);     free(record);     return 0; }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I need help in solving this programming problem. Thank you!

//  ********************* MODIFY ME!!! *********************

#include <stdio.h>
#include <string.h>
#include "lab4_ex1.h"


// Removes or cleans the dangling 'new line' character in stdin
// @param void
// @return none
void flush()
{
    char c;
    while ((c = getchar()) != '\n' && c != EOF);
}

// Creates the course (one course only) by asking the for user input
// @param num course number, e.g. 1,2,3
// @return course
Course createCourse(int num)
{
    Course course;
    //input code here
    return course;
}

// Displays the course 
// @param course number, e.g. 1, 2, 3
// @return none
void displayCourse(Course course)
{
    printf("course name: %s\n", course.name);
    printf("course grade: %0.2f\n", course.grade);
    printf("course units: %d\n", course.unit);
}

// Computes the GPA from three courses, based on the formula in README.md 
// @param courses[TOTAL_COURSE] 
// @return GPA
float computeGPA(Course courses[TOTAL_COURSE])
{
    //  ********************* YOUR CODE HERE *********************
    return 0.0f;
}

// Creates the student by asking for user input 
// @param none
// @return student structure with id, name, degree, courses, and GPA
Student createStudent()
{
    Student student;
    
    // input code here
    
    return student;
}

// Displays the student 
// @param student struct
// @return none
void displayStudent(Student student)
{
    printf("student name: %s\n", student.name);
    printf("ID number: %d\n", student.id);
    printf("degree: %s\n", student.degree);
    for (int i = 0; i < TOTAL_COURSE; i++)
    {
        displayCourse(student.courses[i]);
    }
}

// Displays the student with GPA
// @param student struct
// @return none
void displayStudentGPA(Student student)
{
    printf("%s with ID number %d has a GPA of %.3f\n", student.name, student.id, student.GPA);
}

 

this is the header file

//  ********************* MODIFY ME!!! *********************
#ifndef lab4_ex1_h
#define lab4_ex1_h

#define TOTAL_COURSE 3
#define BUFFER_SIZE 80

typedef struct Course{
    char name[BUFFER_SIZE];
    int unit;
    float grade;
} Course;

typedef struct Student{
    int id;
    char name[BUFFER_SIZE];
    char degree[BUFFER_SIZE];
    Course courses[TOTAL_COURSE];
    float GPA;
} Student;

Student createStudent();
Course createCourse(int);

void displayStudent(Student);
void displayStudentGPA(Student student);
void displayCourse(Course);
float computeGPA(Course courses[TOTAL_COURSE]);

void flush();

#endif

 

this is the main.cpp file

#include <stdio.h>  // needed by printf, scanf
#include <stdlib.h> // needed by malloc
#include "lab4_ex1.h"

int main(void)
{
    int N;
    // Get the number of students N
    do
    {
        printf("Enter number of students to record: "); 
        scanf("%d", &N);
    } while (N < 1);
    flush();

    // Allocate memory to the data of students
    Student *record = (Student *)malloc(N * sizeof(Student));

    // Create student record/s
    for (int i = 0; i < N; i++)
        record[i] = createStudent();

    // Display GPA for all student records
    for (int i = 0; i < N; i++)
        displayStudentGPA(record[i]);

    free(record);
    return 0;
}

Laboratory Activity 4 - Structures
Student Grade Mini-Database
Develop a program that will define and store a student record. The data will be entered by the user. Afterwards,
calculate and display the GPA of each student. You will need to use structure with array.
In case you don't know how to calculate GPA, here's the formula:
Total_Credit_Honors
Total_Units
GPA
Total_Credit_Honors = YTOTAL_COURSE
Grade,*Unit;
-i = 1
Transcribed Image Text:Laboratory Activity 4 - Structures Student Grade Mini-Database Develop a program that will define and store a student record. The data will be entered by the user. Afterwards, calculate and display the GPA of each student. You will need to use structure with array. In case you don't know how to calculate GPA, here's the formula: Total_Credit_Honors Total_Units GPA Total_Credit_Honors = YTOTAL_COURSE Grade,*Unit; -i = 1
Sample Console Input
Expected Console Output
Enter number of students to record: 2
student name: John Anthony
ID number: 10912345
degree: ECE
2
John Anthony
10912345
course 1 name: Physics
course 1 grade: 100
ЕСЕ
Physics
100
course 1 total units: 3
3
course 2 name: Mathematics
Mathematics
course 2 grade: 70
70
course 2 total units: 2
course 3 name: Geology
course 3 grade: 50
2
Geology
50
course 3 total units: 1
1
student name: Jose
Jose
ID number: 10854321
degree: CPE
course 1 name: Physics
course 1 grade: 80
10854321
СРЕ
Physics
80
course 1 total units: 3
3
course 2 name: Mathematics
Mathematics
course 2 grade: 60
60
course 2 total units: 2
course 3 name: Geology
course 3 grade: 90
2
Geology
90
course 3 total units: 1
1
John Anthony with ID number 10912345 has a GPA of 81.667
Jose with ID number 10854321 has a GPA of 75.000
Transcribed Image Text:Sample Console Input Expected Console Output Enter number of students to record: 2 student name: John Anthony ID number: 10912345 degree: ECE 2 John Anthony 10912345 course 1 name: Physics course 1 grade: 100 ЕСЕ Physics 100 course 1 total units: 3 3 course 2 name: Mathematics Mathematics course 2 grade: 70 70 course 2 total units: 2 course 3 name: Geology course 3 grade: 50 2 Geology 50 course 3 total units: 1 1 student name: Jose Jose ID number: 10854321 degree: CPE course 1 name: Physics course 1 grade: 80 10854321 СРЕ Physics 80 course 1 total units: 3 3 course 2 name: Mathematics Mathematics course 2 grade: 60 60 course 2 total units: 2 course 3 name: Geology course 3 grade: 90 2 Geology 90 course 3 total units: 1 1 John Anthony with ID number 10912345 has a GPA of 81.667 Jose with ID number 10854321 has a GPA of 75.000
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY