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.
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 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.
Create a C++ program that follows the specifications below: *Define a struct with 4 or more...
Create a C++ program that follows the specifications below: *Define a struct with 4 or more members. *Application must have at least one user-defined function *Declare an array of your struct using a size of 10 or more *Load the date for each element in your array from a text file *Display the data in your array in the terminal *provide brief comments for each line of code
Using C++ language, create a program that uses a struct with array variables that will loop...
Using C++ language, create a program that uses a struct with array variables that will loop at least 3 times and get the below information: First Name Last Name Job Title Employee Number Hours Worked Hourly Wage Number of Deductions Claimed Then, determine if the person is entitled to overtime and gross pay. Afterwards, determine the tax and net pay. Output everything to the screen. Use functions wherever possible. Bonus Points: Use an input file to read in an unknown...
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of...
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of the word. Next, use the struct to store the word read from a text file call “word.txt” and the length of the word. Print out the word x number of times based on the length of the word as shown below. Also, print a statement with the length and determine if the string length has an odd number or even number of characters. You...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT