// Write a Object Oriented Program to Display Studnet Information
#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<conio.h>
#include<iomanip>
#include<cstring>
using namespace std;
class student
{
public:
char first_name[50], last_name[50];
int roll;
float ban_mark,eng_mark,mat_mark;
};
int main()
{
student infor;
char option, select;
FILE *fp;
fp=fopen("users.txt","rb+");
if (fp == NULL)
{
fp = fopen("users.txt","wb+");
return 0;
}
while(1)
{
system("cls");
cout << "\n\n";
cout << "\t\t****** INFORMATION OF STUDENTS ******";
cout << "\n\n";
cout << "\n \t\t 1. Add Students";
cout << "\n \t\t 2. Show Records";
cout << "\n \t\t 3. Exit";
cout << "\n\n";
cout <<"\t Select What you want:> infor.first_name;
cout << "Last Name : ";
cin >> infor.last_name;
cout << "Roll No : ";
cin >> infor.roll;
cout << "Marks of Bangla : ";
cin >> infor.ban_mark;
cout << "Marks of English : ";
cin >> infor.eng_mark;
cout << "Marks of Mathmetic : ";
cin >> infor.mat_mark;
fwrite(&infor,sizeof(infor),1,fp);
cout << "\n Add Another Record (Y/N) ";
fflush(stdin);
option = getchar();
}
break;
case '2':
system("cls");
rewind(fp);
cout << "=== View the Records in the Database ===";
cout << "\n";
while (fread(&infor,sizeof(infor),1,fp) == 1)
{
cout << "\n";
cout <<"\t Name of Students : "<< infor.first_name << setw(5)<< infor.last_name;
cout << "\n";
cout <<"\t Roll No : " <<infor.roll;
cout << "\n";
cout <<"\t Bangla : " <<infor.ban_mark;
cout << "\n";
cout << "\t English : " <<infor.eng_mark;
cout << "\n";
cout <<"\t Mathmetics : " <<infor.mat_mark<<endl;
cout<<"\t" <<endl<<"================================="<<endl;
}
cout << "\n\n";
system("pause");
break;
case '3':
system("cls");
fclose(fp);
cout << "\n\n";
cout << "\t\t********************************************************"<<endl;
cout << "\t\t* THANKS BY MD.HASMOT HOSSEN. *"<<endl;
cout << "\t\t********************************************************"<<endl;
cout << "\n\n";
exit(0);
}
}
system("pause");
return 0;
}
#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<conio.h>
#include<iomanip>
#include<cstring>
using namespace std;
class student
{
public:
char first_name[50], last_name[50];
int roll;
float ban_mark,eng_mark,mat_mark;
};
int main()
{
student infor;
char option, select;
FILE *fp;
fp=fopen("users.txt","rb+");
if (fp == NULL)
{
fp = fopen("users.txt","wb+");
return 0;
}
while(1)
{
system("cls");
cout << "\n\n";
cout << "\t\t****** INFORMATION OF STUDENTS ******";
cout << "\n\n";
cout << "\n \t\t 1. Add Students";
cout << "\n \t\t 2. Show Records";
cout << "\n \t\t 3. Exit";
cout << "\n\n";
cout <<"\t Select What you want:> infor.first_name;
cout << "Last Name : ";
cin >> infor.last_name;
cout << "Roll No : ";
cin >> infor.roll;
cout << "Marks of Bangla : ";
cin >> infor.ban_mark;
cout << "Marks of English : ";
cin >> infor.eng_mark;
cout << "Marks of Mathmetic : ";
cin >> infor.mat_mark;
fwrite(&infor,sizeof(infor),1,fp);
cout << "\n Add Another Record (Y/N) ";
fflush(stdin);
option = getchar();
}
break;
case '2':
system("cls");
rewind(fp);
cout << "=== View the Records in the Database ===";
cout << "\n";
while (fread(&infor,sizeof(infor),1,fp) == 1)
{
cout << "\n";
cout <<"\t Name of Students : "<< infor.first_name << setw(5)<< infor.last_name;
cout << "\n";
cout <<"\t Roll No : " <<infor.roll;
cout << "\n";
cout <<"\t Bangla : " <<infor.ban_mark;
cout << "\n";
cout << "\t English : " <<infor.eng_mark;
cout << "\n";
cout <<"\t Mathmetics : " <<infor.mat_mark<<endl;
cout<<"\t" <<endl<<"================================="<<endl;
}
cout << "\n\n";
system("pause");
break;
case '3':
system("cls");
fclose(fp);
cout << "\n\n";
cout << "\t\t********************************************************"<<endl;
cout << "\t\t* THANKS BY MD.HASMOT HOSSEN. *"<<endl;
cout << "\t\t********************************************************"<<endl;
cout << "\n\n";
exit(0);
}
}
system("pause");
return 0;
}
No comments:
Post a Comment