Question

In: Computer Science

This project requires the student to create a record (in C++ called a struct). The record...

This project requires the student to create a record (in C++ called a struct). The record should contain several fields of different data types and should allow the user to search the records to find the student with the highest grade. In this project the student should gain an understanding of the nature of records with multiple data types, how to save the records, search the records and retrieve them.  The special problems of maintaining records of multiple data types on a digital machine will be seen.

Solutions

Expert Solution

#include<iostream>
using namespace std;

//structure for a student
struct Student{
   //name, id and grade can be stored
   string name;
   int id;
   double grade;
};

int main() {
  
   //reading number of students
   int n;
   cout << "Enter number of students: ";
   cin >> n;
  
   //array of n students
   Student students[n];
  
   //poupulating data in array of struct
   for(int i = 0 ; i < n ; i ++) {
       cout << "\nEnter details of student " << (i+1) << ": \n";
       cout << "Enter Name: " ;
       cin >> students[i].name;
      
       cout << "Enter student Id: ";
       cin >> students[i].id;
      
       cout << "Enter grade: ";
       cin >> students[i].grade;
   }
  
   //printing data stored in array
   cout << "\nStudent Details are: \n";
       for(int i = 0 ; i < n ; i ++) {
       cout << "\n\nDetails of student " << (i+1) << ": \n";
       cout << "Name: " << students[i].name << endl;
       cout << "Student Id: " << students[i].id << endl;
       cout << "Grade: " << students[i].grade << endl;
   }
  
   //finding out the student having maximum grade
   Student max = students[0];
   for(int i = 1 ; i < n ; i++) {
       if(students[i].grade > max.grade){
           max = students[i];
       }
   }
  
   cout << "\n\nStudent with Highest grade: \n";
   cout << "Name: " << max.name << endl;
   cout << "Student Id: " << max.id << endl;
   cout << "Grade: " << max.grade << endl;
}

IF THERE IS ANYTHING THAT YOU DO NOT UNDERSTAND, OR NEED

MORE HELP THEN PLEASE MENTION IT IN THE COMMENTS SECTION.


Related Solutions

HW_6d - Write a struct object to a binary file. Create a new C++ project and...
HW_6d - Write a struct object to a binary file. Create a new C++ project and name it as:   Cats Create a Source.cpp file. Declare a struct named Cat. (in the Source.cpp file, or in a separate header file) Each Cat object has a name and age. The name data member is a c_string. The age data member is an integer. Ask the user to enter 3 cats. Use a while loop to read the information about one cat entered...
Create a structure in C called BarcelonaPlayer with the following members. struct BarcelonaPlayer { char name[20];...
Create a structure in C called BarcelonaPlayer with the following members. struct BarcelonaPlayer { char name[20]; int age; char country[20]; char Position[20]; double Salary; double Rating; }; First, create an array of BarcelonaPlayer structures. Now, write a function that takes an array of BarcelonaPlayer structures as input and find out the highest paid player among all the players. void highestPaidPlayer(struct BarcelonaPlayer *pl, int size); Create another function that finds all the players from Argentina. void findPlayers(struct BarcelonaPlayer *pl, int size);
C++ HW Aim of the assignment is to write classes. Create a class called Student. This...
C++ HW Aim of the assignment is to write classes. Create a class called Student. This class should contain information of a single student. last name, first name, credits, gpa, date of birth, matriculation date, ** you need accessor and mutator functions. You need a constructor that initializes a student by accepting all parameters. You need a default constructor that initializes everything to default values. write the entire program.
C++ Project Organization Create a project called Project1 and then name and organize the following programs...
C++ Project Organization Create a project called Project1 and then name and organize the following programs under it. Part 1 CircleArea You are going to write a program to compute and output the area of a circle with a radius of 2.5. Think through what you need to do: Create a variable for radius set it to 2.5 Create a variable for area set it to 3.14159 * radius * radius output the value of area Challenge (not required) Generalize...
In this assignment you will build a small C# project that uses… • A struct •...
In this assignment you will build a small C# project that uses… • A struct • A method with a reference parameter • A while-loop • A switch statement and block instructions: Inside the StringHandler struct add a public void method named Abbreviate. The Abbreviate method must take a string parameter that is passed by reference. This method will take the name of a month (January, February, etc.) as its input and convert it to a 3-letter abbreviation of the...
write a Program in C++ Using a structure (struct) for a timeType, create a program to...
write a Program in C++ Using a structure (struct) for a timeType, create a program to read in 2 times into structures, and call the method addTime, in the format: t3 = addTime(t1, t2); Make sure to use add the code to reset and carry, when adding 2 times. Also, display the resultant time using a function: display(t3);
Problem 1 Create a new project called Lab7 Create a class in that project called ListORama...
Problem 1 Create a new project called Lab7 Create a class in that project called ListORama Write a static method in that class called makeLists that takes no parameters and returns no value In makeLists, create an ArrayList object called avengers that can hold String objects. Problem 2 Add the following names to the avengers list, one at a time: Chris, Robert, Scarlett, Clark, Jeremy, Gwyneth, Mark Print the avengers object. You will notice that the contents are displayed in...
Write a C++ programs to: 1. Create a class called Student with four (4) private member...
Write a C++ programs to: 1. Create a class called Student with four (4) private member variables, name (string), quiz, midterm, final (all double type); 2. Include all necessary member functions for this class (at least 1 constructor, 1 get function, and 1 grading function – see #6); 3. Declare three (3) objects of Student type (individual or array); 4. Read from the keyboard three (3) sets of values of name, quiz, midterm, final and assign them to each object;...
Create a class called Student which stores • the name of the student • the grade...
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 the grade field. • Calculate the...
Write in C++: create a Doubly Linked List class that holds a struct with an integer...
Write in C++: create a Doubly Linked List class that holds a struct with an integer and a string. It must have append, insert, remove, find, and clear.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT