Question: C++ Data Persistance Help Redo the code below to make the data persistent. You will have to save information in a file or files so
C++ Data Persistance Help
Redo the code below to make the data persistent. You will have to save information in a file or files so that the application will pick up previously stored data and still operate as intended in Lab1 to
Write a program that allows the user to initially enter information on 4 students and 10 courses. Have the program associate each student to at least four courses for a semester session. The program will display a report showing the assigned courses for each students with the total number of credits.
The student information should include:
1. student ID
2. first name
3. last name
The course information should include:
1. Course ID
2. Course name
3. Number of credits
Design requirement:
A student will be assigned a course through a session. The session should include the following attributes:
1. session ID
2. student ID
3. course ID
4. start date
5. end date
.
See Code Below:
course.h
#include
struct course { string CourseName; string CourseID; int numberOfCredits; };
student.h
#include
struct student { string fname; string lname; string stuID; };
session.h
#include
struct session { int sessionID; string stuID; string courseID; string startDate; string endDate; int totalCredits; };
main.cpp
#include
void fillStudents(student arg[], int size) { for (int i = 0; i < size; i++) { cout <<"Student #"<>arg[i].stuID; cout <<"Enter the first name (i.e Ryan): "; cin >>arg[i].fname; cout <<"Enter the last name (i.e Brown): "; cin >>arg[i].lname; system("CLS"); } }
void fillCourses(course c[], int size) { for (int i = 0; i < size; i++) { cout <<"Course #"<>c[i].CourseName; cout <<"Enter course ID (i.e CS-230 (put - instead of spaces)): "; cin >>c[i].CourseID; cout <<"Enter number of credits (i.e 3): "; cin >>c[i].numberOfCredits; system("CLS"); } }
string CourseN(int choice, course ch[]) { switch(choice) { case 1: return ch[0].CourseID+" "+ch[0].CourseName; break; case 2: return ch[1].CourseID+" "+ch[1].CourseName; break; case 3: return ch[2].CourseID+" "+ch[2].CourseName; break; case 4: return ch[3].CourseID+" "+ch[3].CourseName; break; case 5: return ch[4].CourseID+" "+ch[4].CourseName; break; case 6: return ch[5].CourseID+" "+ch[5].CourseName; break; case 7: return ch[6].CourseID+" "+ch[6].CourseName; break; case 8: return ch[7].CourseID+" "+ch[7].CourseName; break; case 9: return ch[8].CourseID+" "+ch[8].CourseName; break; case 10: return ch[9].CourseID+" "+ch[9].CourseName; break; default: cout<<"Invalid decison!! Good Bye!"< int creditTotal(int sel, course ch[]) { switch(sel) { case 1: return ch[0].numberOfCredits; break; case 2: return ch[1].numberOfCredits; break; case 3: return ch[2].numberOfCredits; break; case 4: return ch[3].numberOfCredits; break; case 5: return ch[4].numberOfCredits; break; case 6: return ch[5].numberOfCredits; break; case 7: return ch[6].numberOfCredits; break; case 8: return ch[7].numberOfCredits; break; case 9: return ch[8].numberOfCredits; break; case 10: return ch[9].numberOfCredits; break; default: cout<<"Invalid Decision!! Good Bye!"< void fillSession(student arg[], course c[], session s[]) { int c1, c2, c3, c4; string ch1, ch2, ch3, ch4; string startDate, endDate; int cr1, cr2, cr3, cr4; for (int i = 0; i < 4; i++) { for(int j = 0; j < 10; j++) { cout<<"class #"< void display_report(student s[], course c[], session se[]) { for (int i = 0; i < 4; i++) { cout<<"Student ID: "< int main() { cout<<"Welcome to the CS 230 Data Structures class add program!"< session sessions[4]; fillSession(stu, courses, sessions); //display a report showing each student with his/her courses //show the total number of credits for each student cout<<"Please find your name and other important information below to see your classes and credit totals: "<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
