USING C++ A - Create an array of 15 student records that should not be sorted. B
ID: 3886655 • Letter: U
Question
USING C++
A - Create an array of 15 student records that should not be sorted.
B - Create a liked list of 15 student records. Each node is a node of one student record from the above unsorted array.
(Append Function)
C - Each student record consists of student ID, student name, Student address, and GPA.
- The student records must be defined as student object class with member functions. (No class definition will be no credit for the project.)
Execution and output:
Display the student records in the unsorted array
Display the student records from the unsorted linked list
D - Created a second linked list by Inserting the student records from the unsorted array to the second linked list by using insert function. (Insert Function)
(If you insert correctly, the resulting linked list is sorted.)
- Execution and output
Display the student records from the unsorted linked list (same as project 1.)
Display the sorted student records from the 2nd linked list.
The output of the 2nd linked list should be sorted by using “insert” function from beginning of the list.
Do not use SORT Program. Using it will get penalty.
F - Delete the nth record from the middle of the sorted list and display the resulting list. (Delete function.)
G - Insert a mth record to the middle and display the resulting sorted list.
Explanation / Answer
//A. Create an array of 15 students records that should not be sorted.
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class Student{
public:
long int sID;
string sName;
string sAdd;
float sGPA;
void getdata();
void display();
};
void Student::getdata(){
cout<<"Enter the Student ID: ";
cin>>sID;
cout<<"Enter the Student Name: ";
cin.ignore();
getline(cin, sName);
cout<<"Enter the Student Address: ";
getline(cin, sAdd);
cout<<"Enter the Student GPA: ";
cin>>sGPA;
}
void Student::display(){
cout<<"Student ID: "<<sID;
cout<<"Student Name: "<<sName;
cout<<"Student Address: "<<sAdd;
cout<<"Enter the Student GPA: "<<sGPA;
}
int main(){
Student sRecord[15]; //Creating array of 15 records..
// Taking details of 15 records from the user..
for(int i=0;i<15;i++){
cout<<"Enter the details of the Student "<<i+1<<" ";
sRecord[i].getdata();
}
//Displaying 15 records for array..
for(int i=0;i<15;i++){
cout<<"Displaying Student Record "<<i+1<<" ";
sRecord[i].display();
}
}
// Program for part A ends here...
I am currently working on other parts of the program. Please look back after some time.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.