Question

C++ Object Oriented Programming Programming Assignment #4 Structures Create a structure representing a student. The member va

Your output should be similar to this screen it calculates the average of the three highest urades. Enter and for its 12 H ag

I'm falling behind on my hw and I can really use a hand with using structures in C,++

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

Done accordingly. Comment for further help. Please uprate

Code:

#include<iostream>
#include<string>
using namespace std;

typedef struct{
   string name;
   int id;
   double grades[4];
   double average;
}Student;

void readStudentData(Student &student){

   cout<<"Please give student name :";
   cin>>student.name;
   cout<<"Please give student id :";
   cin>>student.id;
   for(int j=0;j<4;j++){
       cout<<"Please give grade for Test "<<j+1<<" :";
       cin>>student.grades[j];
   }
}

void calculateAverage(Student *student){
   double min;
   double sum;

   min=student->grades[0];
   sum=student->grades[0];
   for(int j=1;j<4;j++){
       sum=sum+student->grades[j];
       if(student->grades[j]<min)
           min=student->grades[j];
   }
   sum=sum-min;
   student->average=sum/3;
}


void printStudentData(Student student){
   cout<<"Student Name :"<<student.name<<endl;
   cout<<"Student ID :"<<student.id<<endl;
   for(int j=0;j<4;j++){
       cout<<"Grade for Test "<<j+1<<" :"<<student.grades[j]<<endl;
   }
   cout<<"Average of the highest three grades is:"<<student.average<<endl<<endl;
}

void main(){
   Student students[100];
   int size=0;
   Student temp;
   string choice;
   cout<<"*********************************************\n";
   cout<<"This program will get student details and print them after calculating average.\n";
   cout<<"\n*********************************************\n\n";
   while(size<100){
       readStudentData(temp);
       cin.ignore();
       cin.clear();
       students[size]=temp;
       calculateAverage(&temp);
       printStudentData(temp);
       size++;
       cout<<"Do you want to contiue :(Press n to exit)";
       cin>>choice;
       if(choice=="n")
           break;

   }

   system("pause");
}

Output:

************************************** This program will get student details and print them after calculating average. Please

Add a comment
Know the answer?
Add Answer to:
I'm falling behind on my hw and I can really use a hand with using structures...
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
  • DO NOT USE ARRAYS IF YOU KNOW ABOUT ARRAYS, I WANT YOU TO USE 3 VARIABLES,...

    DO NOT USE ARRAYS IF YOU KNOW ABOUT ARRAYS, I WANT YOU TO USE 3 VARIABLES, IT WILL FORCE YOU TO USE COMPOUND LOGICAL STATEMENTS FOR THE IF STATEMENTS. Create a program that will display a menu to the user. The choices should be as follows: Enter 3 grades Show average (with the 3 grades) and letter grade Show highest grade Show lowest grade Exit If you want to put the menu into a function you may. The program should...

  • First, create two inputs that can be stored in variables consisting of a student's name. When...

    First, create two inputs that can be stored in variables consisting of a student's name. When the program begins ask "Who is the first student?" followed by "Who is the second student?" You only have to have two students for this program. Ask the user for the scores for the last three test grades for each of the students .   After the user has entered both names, and three scores for each, the program should display the following as output:...

  • C++ Programming

    PROGRAM DESCRIPTIONIn this project, you have to write a C++ program to keep track of grades of students using structures and files.You are provided a data file named student.dat. Open the file to view it. Keep a backup of this file all the time since you will be editing this file in the program and may lose the content.The file has multiple rows—each row represents a student. The data items are in order: last name, first name including any middle...

  • using java Program: Please read the complete prompt before going into coding. Write a program that...

    using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...

  • ****THIS IS A 2 PART QUESTION! I ONLY NEED THE ANSWER TO PART 2 ON HOW...

    ****THIS IS A 2 PART QUESTION! I ONLY NEED THE ANSWER TO PART 2 ON HOW TO SEND THE DATA SERIALIZED**** Write a c# program that stores student grades in a text file and read grades from a text file.  The program has the following GUI: There are four buttons: Create File, Save Case, Close File and Load File.  Initially, only the Create File and Load File buttons are enabled.  If the user clicks the Create File button, a Save File Dialog window...

  • Hi this is C++, I'm really struggle with it please help me.... ************************ Here is the...

    Hi this is C++, I'm really struggle with it please help me.... ************************ Here is the original high score program,: Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look exactly like this: Enter the name for score #1: Suzy Enter the score for...

  • Write a program that performs the following: 1. Presents the user a menu where they choose...

    Write a program that performs the following: 1. Presents the user a menu where they choose between:              a. Add a new student to the class                           i. Prompts for first name, last name                           ii. If assignments already exist, ask user for new student’s scores to assignments              b. Assign grades for a new assignment                           i. If students already exist, prompt user with student name, ask them for score                           ii. Students created after assignment will need to...

  • In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a tes...

    In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...

  • Using C programming For this project, you have been tasked to read a text file with student grade...

    Using C programming For this project, you have been tasked to read a text file with student grades and perform several operations with them. First, you must read the file, loading the student records. Each record (line) contains the student’s identification number and then four of the student’s numerical test grades. Your application should find the average of the four grades and insert them into the same array as the id number and four grades. I suggest using a 5th...

  • I'm just a beginner in programming,how to make this program more simple without using #include<iostream> and #include<redex> here is the question Terms to know: If-else statement,for.....

    I'm just a beginner in programming,how to make this program more simple without using #include<iostream> and #include<redex> here is the question Terms to know: If-else statement,for..while..do while,loops,pointer,address,continue,return,break. Create a C++ program which contain a function to ask user to enter user ID and password. The passwordmust contain at least 6 alphanumeric characters, 1 of the symbols !.@,#,$,%,^,&,* and 1 capital letter.The maximum allowable password is 20. Save the information. Test the program by entering the User ID and password. The...

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