Professional Documents
Culture Documents
Computer Programming
Final Semester Project
Code
#include <iostream> //Initializing
#include <cstring>
#include <istream>
#include <string>
using namespace std;
struct student //Structure types
{
string name;
string dob;
int age;
string address;
string courses;
char grade;
string data="Data is removed";
};
int main ()
{
student s1,s2,s3; //3 student records
cout<<"Please select an option"<<endl;
cout<<"1. Add new record of the student"<<endl;
cout<<"2. Remove the record"<<endl;
cout<<"3. Update the record"<<endl;
cout<<"4. Search for Particular student"<<endl;
int n,n11,n22;
cin>>n;
if (n==1) //1st student new record
{
int c1;
cout<<"Now you have to enter a new record of a student"<<endl;
cout<<"Enter student's name : ";
cin>>s1.name;
cout<<endl;
cout<<"Enter the date of birth : ";
getline(cin,s1.dob);
cout<<endl;
cout<<"Enter age : ";
cin>>s1.age;
cout<<endl;
cout<<"Enter the address : ";
getline(cin,s1.address);
cout<<endl;
cout<<"Enter your number of courses : "; //Entering number of
courses and assigning Grades
cin>>c1;
int marks [5];
for (int i=0;i<=c1;i++)
{
cout<<"Enter the name of "<<i+1<<" course : ";
cin>>s1.courses[i];
cout<<"Now enter the marks : ";
cin>>marks[i];
}
for (int i=0;i<=c1;i++) //Assigning Grades of all courses
{
if (marks[i]>84 && marks[i]<101)
{
cout<<"Your grade in "<<i+1<<" course is : ";
s1.grade='A';
}
else if (marks[i]>69 && marks[i]<85)
{
cout<<"Your grade in "<<i+1<<" course is : ";
s1.grade='B';
}
else if (marks[i]>59 && marks[i]<70)
{
cout<<"Your grade in "<<i+1<<" course is : ";
s1.grade='C';
}
else if (marks [i]>49 && marks[i]<61)
{
cout<<"Your grade in "<<i+1<<" course is : ";
s1.grade='D';
}
else
cout<<"Your grade in "<<i+1<<" course is : ";
s1.grade='F';
}
}
Code Explanation
• Main Screen appears to have 4 options.
1. New Record
2. Remove the record
3. Upgrade record
4. Search for particular student
If user select (1), program ask the user to enter the record of student 1,2 and 3 respectively.
If user select (2), program ask the user to remove the record of student 1,2 and 3 respectively.
If user select (3), program ask the user to update the record of student 1,2 and 3 respectively.
If user select (4), program ask the user to search for the particular student and displays his data.