Advertisement
Guest User

System

a guest
Mar 3rd, 2019
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.04 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <cstdlib>
  4. using namespace std;
  5. int main()
  6. {
  7.     string g;
  8.     string e;
  9.     char degree[30];
  10.     char b[30];
  11.     int a;
  12.     string k;
  13.     int c;
  14.     int j;
  15.     float y;
  16.     float w;
  17.     float m;
  18.     int n;
  19.     string d;
  20.     string duser, dpass;
  21.     string inputuser, inputpass;
  22.     string data,data2;
  23.     ifstream infile;
  24.     infile.open("Security.txt");
  25.     getline(infile,data);  
  26.     duser = data;
  27.     getline(infile,data);
  28.     dpass = data;  
  29.  
  30.     cout << "Student Information System \n";
  31.     cout << "Login \n";
  32.         cout << "Username: ";
  33.     cin >> inputuser;
  34.         cout << "\nPassword: ";
  35.     cin >> inputpass;
  36.     while (inputuser != duser || inputpass != dpass)
  37.     {
  38.         cout << "Incorrect! Please relogin \n";
  39.         cout << "Username: \n";
  40.         cin >> inputuser;
  41.         cout << "\nPassword: ";
  42.         cin >> inputpass;
  43.      }
  44.      if (inputuser == duser && inputpass == dpass)
  45.      {
  46.         system("pause");
  47.         system("cls");
  48.         cout << "Welcome to Student Information System! \n";
  49.      }
  50. cout << "1. Student Information \n";
  51. cout << "2. Quit \n";
  52. cin >> j;
  53.  
  54. if (j == 1)
  55. {
  56.     cout << "   1. Add \n";
  57.     cout << "   2. Edit \n";
  58.     cout << "   3. Back to Main Menu \n";
  59.     cin >> c;
  60.     if (c==1)
  61.     {
  62.             cout << "Enter your ID Number: ";
  63.             cin >> k;
  64.             k+= ".txt";
  65.             ofstream addfile;
  66.             addfile.open(k.c_str());
  67.         cout << "Input name: ";
  68.         cin.getline(b,30);
  69.         getline(cin,data);
  70.         addfile << data << endl;
  71.         cout <<"Enter your College Year: ";
  72.         cin >> a;
  73.     while( a < 0 || a > 4)
  74.     {
  75.         cout <<"Grade level not recognized! Re Enter Grade level! ";
  76.         cin >> a;
  77.     }
  78.  
  79.   addfile << a << endl;
  80.    cin.ignore();
  81.     cout << "Enter your Degree and Specialization: ";
  82.     getline(cin,data);
  83.     addfile << data << endl;
  84.     cout <<"Enter your Section: ";
  85.     getline(cin,data);
  86.     addfile << data << endl;
  87.     cout <<"Enter your Academic Year: ";
  88.     getline(cin,data);
  89.     addfile << data << endl;
  90.     cout <<"Enter your Subject: ";
  91.     getline(cin,data);
  92.     addfile << data << endl;
  93.  
  94.     cout <<"Enter your midterm grade: ";
  95.     cin >> y;
  96.     while (y<60 || y > 100)
  97.     if (y<60)
  98.     {
  99.         cout <<"Invalid Grade! Please re enter Midterm Grade! ";
  100.         cin >> y;
  101.     }
  102.     else if (y>100)
  103.     while (y>100 || y < 60)
  104.     {
  105.         cout <<"Invalid Grade! Please re Midterm Grade! ";
  106.         cin >> y;
  107.     }
  108. addfile << y << endl;
  109.     cout <<"Enter your final grade: ";
  110.     cin >> w;
  111.     if (w<60)
  112.     while (w < 60 || w > 100)
  113.     {
  114.         cout <<"Invalid Grade! Please re enter Final Grade! ";
  115.         cin >> w;
  116.     }
  117.     else if (w>100)
  118.     while (w > 100 || w < 60)
  119.     {
  120.         cout <<" Invalid Grade! Please re enter Final Grade! ";
  121.         cin >> w;
  122.     }
  123.    
  124. addfile << w << endl;
  125.     m =(y + w) / 3;
  126.     cout <<"Here is your total grade: " << m;
  127.     if (m<60)
  128.     {
  129.         cout <<" No Grade! Please re enter again! \n";
  130.     }
  131.     else if (m>100)
  132.     {
  133.         cout <<" No Grade! Please re enter again! \n";
  134.     }
  135.     addfile << m << endl;
  136.     }
  137.     else if (c==2)
  138.     {
  139.             cout << "Please input the ID Number you wish to read ";
  140.             cin >> d;
  141.             d+=".txt";
  142.             ifstream myfile;
  143.             myfile.open(d.c_str());
  144.             getline(myfile,data);
  145.             cout <<"Full name: " << data << endl;
  146.              getline(myfile,data);
  147.             cout << "College Year: " << data << endl;
  148.              getline(myfile,data);
  149.             cout << "Degree & Specialization: " << data << endl;
  150.             getline(myfile,data);  
  151.             cout << "Section: " << data << endl;
  152.              getline(myfile,data);
  153.             cout << "School Year: " << data << endl;
  154.              getline(myfile,data);
  155.             cout << "Subject: " << data << endl;
  156.              getline(myfile,data);
  157.             cout << "Midterm Grade: " << data << endl;
  158.              getline(myfile,data);
  159.             cout << "Final Grade: " << data << endl;
  160.              getline(myfile,data);
  161.             cout << "Total Grade: " << data << endl;
  162.              getline(myfile,data);
  163.             cout << data << endl;
  164.            
  165.     }
  166.     else if ( c==3 )
  167.     {
  168.         cout << "1. Student Information \n";
  169.         cout << "2. Quit \n";
  170.         cin >> j;
  171.     }
  172.     else if (j == 2)
  173.     {
  174.         cout << "Goodbye! ";
  175.         return EXIT_SUCCESS;
  176. }
  177. }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement