Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include<stdlib.h>
- #include<string.h>
- #include<ctime>
- using namespace std;
- void signIn();
- void signUp();
- void admin();
- int main(){
- int choicE;
- cout<<"====================================================="<<endl;
- cout<<"=============College Management System==============="<<endl;
- cout<<"====================================================="<<endl;
- cout<<endl<<endl;
- cout<<"1) Student sign in"<<endl;
- cout<<"2) Student sign up"<<endl;
- cout<<"3) Admin"<<endl<<endl;
- cout<<"Enter Your Choice: ";
- cin>>choicE;
- switch(choicE)
- {
- case 1:
- signIn();
- break;
- case 2:
- signUp();
- break;
- case 3:
- admin();
- break;
- default:
- system("cls");
- cout<<"Wrong choice!\nTry again!"<<endl;
- main();
- }
- return 0;
- }
- void signIn(){
- int counter,id, acount;
- string user,pass,u,p,m;
- system("cls");
- cout<<"please enter the following details"<<endl;
- cout<<"USERNAME :";
- cin>>user;
- cout<<"PASSWORD :";
- cin>>pass;
- ifstream f("student.txt");
- while(f>>id>>u>>m>>p)
- {
- if(u==user && p==pass)
- {
- counter=1;
- system("cls");
- }else
- {
- cout<<"Either username or password is incorrect";
- main();
- }
- }
- f.close();
- if(counter==1)
- {
- int choiCe;
- cout<<"\nWelcome"<<user<<"!"<<endl<<endl;
- cout<<"1) Ask Question"<<endl;
- cout<<"2) Check Messages"<<endl;
- cout<<"3) Account info"<<endl;
- cout<<"Enter anything else to exit."<<endl<<endl;
- cout<<"Enter your choice: ";
- cin>>choiCe;
- cout<<endl;
- if(choiCe==1){
- string question;
- cout<<"Enter Your Question: "<<endl;
- cin>>question;
- getline(cin, question);
- cout<<question<<endl;
- ofstream g("question.txt",ios::app);
- g<<question<<endl;
- cout<<"Question will be answered shortly. Come back later!"<<endl;
- }else if(choiCe==2){
- string q,q2,a;
- int count;
- ifstream y("question.txt");
- ifstream x("answer.txt");
- while(y>>q && x>>q2>>a)
- {
- if(q==q2)
- {
- count=1;
- }
- }
- y.close();
- x.close();
- if(count==1){
- cout<<q2<<a;
- }
- }else if(choiCe==3){
- ifstream h("student.txt");
- while(h>>id>>u>>m>>p){
- if(true){
- acount=1;
- }
- }
- h.close();
- if(acount==1){
- int no;
- cout<<"Major: "<<m<<endl;
- cout<<"Username: "<<u<<endl;
- cout<<"Password: "<<p<<endl;
- cout<<"Press 1 to exit: ";
- cin>>no;
- if(no==1){ //16777216
- main();
- }
- }
- }else{
- main();
- }
- }
- }
- void signUp(){
- string nuser,npass, nmajor;
- string fname, lname;
- system("cls");
- cout<<"Enter First Name: ";
- cin>>fname;
- cout<<"\nEnter Last Name: ";
- cin>>lname;
- cout<<"\nCreate a Username: ";
- cin>>nuser;
- cout<<"\nEnter Major: ";
- cin>>nmajor;
- cout<<"\nEnter the password: ";
- cin>>npass;
- int id=rand();
- ofstream i("student.txt",ios::app);
- i<<id<<' '<<nuser<<' '<<nmajor<<' '<<npass<<endl;
- system("cls");
- cout<<"\nRegistration Sucessful\n";
- cout<<"Your ID is: "<<id<<"\n Remember it!";
- main();
- }
- void admin()
- {
- int adpass, choIce;
- cout<<"Enter Password: "<<adpass<<endl;
- if(adpass==1234)
- {
- cout<<"1) View Student Info"<<endl;
- cout<<"2) Answer Questions"<<endl;
- cout<<"3) Exit"<<endl<<endl;
- cout<<"Enter your choice: "<<choIce;
- if(choIce==1)
- {
- int aid,acount,id;
- string u,m,p;
- cout<<"Enter student ID"<<aid;
- ifstream j("student.txt");
- while(j>>id>>u>>m>>p){
- if(id==aid){
- acount=1;
- }
- }
- j.close();
- if(acount==1){
- int no;
- cout<<"Major: "<<m<<endl;
- cout<<"Username: "<<u<<endl;
- cout<<"Password: "<<p<<endl;
- cout<<"Press 1 to exit: "<<no;
- if(no==1){
- main();
- }
- }
- }else if(choIce==2)
- {
- fstream l("question.txt");
- if(l.is_open()){
- cout<<l.rdbuf();
- }
- l.close();
- string q,a;
- cout<<"Enter the question you would like to answer:"<<endl;
- getline(cin,q);
- cout<<"Enter the answer:"<<endl;
- getline(cin,a);
- ofstream z("answer.txt",ios::app);
- z<<q<<a<<endl;
- }else{
- main();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement