Question

Write a C++ program that defines a structure called StudentInfo for records consisting of a student’s...

Write a C++ program that defines a structure called StudentInfo for records consisting of a student’s ID, age, final grade for math, final grade for reading, and final grade for music. Define an array of such records to hold up to eight students’ records that the user input students’ information from the keyboard. Then compute and print out the average of their math grades and average of reading, and each student’s average grade of math, reading and music

.

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

C++ Program:

/* C Program that reads student data from user and stores in struct Array and displays their averages */

#include <iostream>

using namespace std;

//Structure definition
struct StudentInfo
{
//Student data
int id;
int age;
double mathGrade;
double readingGrade;
double musicGrade;
};

//Main function
int main()
{
int i;

double sumMathGrade = 0, sumReadingGrade = 0, sumMusicGrade = 0, sumGrade = 0;

double avgMathGrade, avgReadingGrade, avgMusicGrade, avgGrade;

//Array of 8 students
struct StudentInfo students[8];

//Reading data from user
cout << "\n Input Student data as id [Space] age [Space] mathGrade [Space] readingGrade [Space] musicGrade [Space]: \n\n ";

//Looping over each student data
for(i=0; i<8; i++)
{
cout << "\n Student " << (i+1) << " data: ";

//Reading student data
cin >> students[i].id >> students[i].age >> students[i].mathGrade >> students[i].readingGrade >> students[i].musicGrade;
}

//Looping over each student data
for(i=0; i<8; i++)
{
//Calculating sum of grades
sumGrade = students[i].mathGrade + students[i].readingGrade + students[i].musicGrade;

//Calculating average of grades
avgGrade = sumGrade / (double)3;

//Printing individual average grade
cout << "\n Student Id: " << students[i].id << " \t Average grade of math, reading and music : " << avgGrade ;

//Accumulating each grade
sumMathGrade += students[i].mathGrade;
sumReadingGrade += students[i].readingGrade;
sumMusicGrade += students[i].musicGrade;
}

//Finding average of each grade
avgMathGrade = sumMathGrade / (double)8;
avgReadingGrade = sumReadingGrade / (double)8;
avgMusicGrade = sumMusicGrade / (double)8;

//Printing average of each grades
cout << "\n\n Average of math Grades: " << avgMathGrade;
cout << "\n\n Average of reading Grades: " << avgReadingGrade;
cout << "\n\n Average of music Grades: " << avgMusicGrade << " \n";

return 0;
}

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sample Output:

CATCStudentsInformation bin Debug StudentsInformation.exe Input Student data as id [Space] age [Space] mathGrade [Space] read

Add a comment
Know the answer?
Add Answer to:
Write a C++ program that defines a structure called StudentInfo for records consisting of a student’s...
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
  • 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...

  • Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and...

    Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and his/her course names with grades. ? Your system should allow the user to input, update, delete, list and search students’ grades. ? Each student has a name (assuming no students share the same name) and some course/grade pairs. If an existing name detected, user can choose to quit or to add new courses to that student. ? Each student has 1 to 5 courses,...

  • Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student...

    Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student gradebook using a two-dimensional array. It should allow the user to enter the number of students and the number of assignments they wish to enter grades for. This input should be used in defining the two-dimensional array for your program. For example, if I say I want to enter grades for 4 students and 5 assignments, your program should define a 4 X 5...

  • Problem Specification: Write a C++ program to calculate student’s GPA for the semester in your class. For each student, the program should accept a student’s name, ID number and the number of courses...

    Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...

  • Structures in C++ :- 1. Write a program that declares a structure to store the code...

    Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...

  • Write a C++ program to keep records and perform statistical analysis for a class of 20...

    Write a C++ program to keep records and perform statistical analysis for a class of 20 students. The information of each student contains ID, Name, Sex, quizzes Scores (2 quizzes per semester), mid-term score, final score, and total score. The program will prompt the user to choose the operation of records from a menu as shown below: ==============================================                                            MENU =============================================== 1. Add student records 2. Delete student records 3. Update student records 4. View all student records 5. Calculate...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • Structures in C++ :- 2. Write a program that declares a structure to store the distance...

    Structures in C++ :- 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then display the record of the winner. 3. Write a program that declares a structure to store income, tax rate and tax of a person. The program defines an array of structure to store the records of five person. It inputs income...

  • ( Object array + input) Write a Java program to meet the following requirements: 1. Define...

    ( Object array + input) Write a Java program to meet the following requirements: 1. Define a class called Student which contains: 1.1 data fields: a. An integer data field contains student id b. Two String data fields named firstname and lastname c. A String data field contains student’s email address 1.2 methods: a. A no-arg constructor that will create a default student object. b. A constructor that creates a student with the specified student id, firstname, lastname and email_address...

  • Java - In NetBeans IDE: • Create a class called Student which stores: - the name...

    Java - In NetBeans IDE: • Create a class called Student which stores: - the name of the student - the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into...

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