Using Structure and Function in Program

i m beginner and i don't know about using structure and function, please help me to solution of this assignment
XYZ University needs a system for student’s courses and their semester details. A data entry operator needs to enter student’s data in to the system, and then the system will show the report of student semester information. Following data will be used by the system.

• Course code
• Course name
• Semester

The system will allow entering data for five courses at a time and will input course code along with course name, later the system will format the report in a more readable form.

Your task is to:
Write a C++ program to implement the above mentioned interface

• Your program should provide the user with options to enter data for courses along with course code. e.g.
Enter course name along with course code: CS201 Introduction to Programming


• After taking course information from user your program should prompt user to enter semester information.
e.g. Enter Semester: Fall 2016

• The program should input data for five courses and semester.
• Use structure name “course” in your program.
• Use separate functions for taking user inputs, displaying and formatting outputs.
e.g. InputCourses(),DisplayHeader(),DisplayCourses(),FormatCourse(---) etc

output
Enter course name along with course code: CS201 Introduction to Programming
Enter Semester: Fall 2016
Enter course name along with course code:CS602 data communication
Enter Semester: spring 2017
Enter course name along with course code:mth310 mathematics
Enter Semester: Fall 2016


S.no^^course code^^^^^^^^^course name^^^^^^^semester ^^^^launching year
------------------------------------------------------------------------------------------------------------
1 ^^^^^CS201^^^^^^^Introduction to Programming^^^^Fall 2016^^^^2016
2 ^^^^^CS602^^^^^^^^^^^^^data communication^^spring 2017^^^^2017
3 ^^^^mth310^^^^^^^^^^^^^^^^^^mathematics^^^^Fall 2016^^^^2016

Please check the code this is correct.

#include<iostream>
#include<cstring>

using namespace std;

struct Course{
string course;
string semesters;

};

void DisplayHeaders();
void InputCourse();
void DisplayCourse(string Ccode[5],string Cname[5],string Csemester[5],string Cyear[5]);

int main()
{
cout <<"KHUSHDIL KAMAL MC150402945"<<"\n\n";
InputCourse();


}

void DisplayHeaders()
{
cout<<"\n# Course Code \t\t Course Name \t\t Semester\tLounching Year"<<endl;
cout<<"\n--------------------------------------------------------------------------------\n"<<endl;
}

void InputCourse()
{
Course Name[5];
string CourseCode[5];
string CourseName[5];
string Semester[5];
string Year[5];

for (int i=0; i<5; i++)
{
cout<<"Enter Course name along with course code: ";
getline(cin,Name[i].course);
cout<< "Enter Semester: ";
getline(cin,Name[i].semesters);
CourseCode[i]= Name[i].course.substr(0,6);
Semester[i] = Name[i].semesters;
CourseName[i]= Name[i].course.substr(6);
Year[i]= Name[i].semesters.substr(Name[i].semesters.size()-4);
}
DisplayHeaders();
DisplayCourse(CourseCode,CourseName,Semester,Year);
}

void DisplayCourse(string Ccode[5],string Cname[5],string Csemester[5],string Cyear[5])
{
for(int i= 0;i<5; i++)
{
std::cout.width(1); std::cout << std::right << i+1<<" ";
std::cout.width(6); std::cout << std::right << Ccode[i]<<"\t";
std::cout.width(30); std::cout << std::right << Cname[i] << "\t";
std::cout.width(12); std::cout << std::right << Csemester[i] << "\t";
std::cout.width(4); std::cout << std::right << Cyear[i] << endl;

}
}
Last edited on
Topic archived. No new replies allowed.