Below I have provided my current code.
The 4th image is the result that I am trying to get. I would
like to get some help in the int main() section of my
code.
I don't really know how to call my function prototypes. Thank
you in advance.
#include <iomanip> #include <iostream> #include <string> #include <cstdlib> using namespace std; class student { public: student(); student(string id, string name, int crds, double GPA); string getSname(); void setSname(string sname); void inputValuesForOneStuObjO; void displayOneStuObj(); bool compareNames(student s2); int fillSturecs(student s[], int capacity); void displaySturecs(student s[], int n); void sortStuRecsByName(student s[], int n); int linearSearchForName(student s[], int n; string key); int binarySearchForName(student s[], int n; string key); private: string sid; string sname; int credits; double gpa; }; /// /// /// int main() { WIT/Not Sure how to call the fillstukese student s[], int capacity); return 0; }
student::student() { sid = "No ID": sname = "No Name" : credits = m; gpa = 2.0: } student::student(string id, string name, int srds, double GPA) { sid = id; sname = name: credits = crds: gpa = GPA: } string student::getSname() { return sname: } void student::setsname(string name) { sname } void student::inputValuesForOneStuobj() { cin >> sid >> sname >> credits >> gpa; } void student::displayOneStuobj() { cout <<" "<< sid <<" "<< sname << " " << credits<< "" <gpa<<"\n"; } = name bool students compareNames (student s2) { if (sname > 52.sname) return true; else return false; } int student:fillsturecs(student s[], int capacity) { cout << "You can enter up to " << capacity << "student records, How many? "; cin >> ni cout << "Enter the following student info. sid, name, credits, gpa: "; for (int i = 0; i<n; i++) { s[ilinputValuesForOneStuobj(); int n; return n; } }
Joid student::displaySturecs(student s[], int n) { for (int i = 0; i<n; i++) { cout << sid << sname < credits « gpa; s[il.displayOneStuobj(); } } void student::sortSturecsByName(student s[], int n) { student temp: for (int i = 0; i<n - 1; ++i) { for (int j = i + 1; j<n; ++i) { if (s.sname.compare (s[j].sn snane) > 0) { temp = 5 s; s s[jl: s[j] temp: } } } int student: linear SearchForName(student s[], int n, string key) { int pos = -1; for (int i = 0; i < n; i++) { if (s[il.getSname() = key) { pos = i; return pos; } } } } int student::binary SearchForName(student s[], int n, string key) { int low = @, high = n - 1, mid; while (Low <= high) { mid = (Low + high) / 2: if (s[mid) .sid key) return mid; else if (s[mid). sid > key) high = nid - 1; else Low = mid + 1; } return -1; }
X Select Microsoft Visual Studio Debug Console You may enter up to 10 student records. How many? 3 Enter values for a student record in the order of: sid, sname, credits, and gps : --> Student [1]: Enter sid, name, credits completed, and gpa for the student: S1111 John 33 3.33 --> Student (2]: Enter sid, name, credits completed, and gpa for the student: S2222 Anna 44 3.44 --> Student (3]: Enter sid, name, credits completed, and gpa for the student: 53333 Alex 55 3.55 *** Student Progress Report *** SID NAME CREDITS GPA s1111 S2222 S3333 John Anna Alex 33 44 55 3.33 3.44 3.55 Testing linear Search(...) function: Enter sname for a student to be searched --> Alex "Alex"is found in sname[2]. Testing binarySearch(...) function: The student array must be sorted by sname. So we perform the sort operation first. Performing sort ... After soringing student records by name in alphabetical order: *** Student Progress Report *** SID NAME CREDITS GPA 55 S3333 s2222 s1111 Alex Anna John 44 33 3.55 3.44 3.33 Enter sname for a student to be searched --> John "John"is found in sname[2].
Below I have provided my current code. The 4th image is the result that I am trying to get. I would like to get some hel
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Below I have provided my current code. The 4th image is the result that I am trying to get. I would like to get some hel
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!