Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Revised Student Record Code written in C++ 2011-12
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#1
Revised Student Record Code written in C++ 2011-12

This is our new and revised program...
for the registration:
I thank all of those people who helped me.
for the search function:
so I've manage to, actually my teammate managed to get a search function workingConfusedmileys15:
for edit function:

Code:
#include <iostream> #include <string> #include <fstream> #include <cctype> #include <Windows.h> using namespace std; struct Record { string FName, LName, MName, Email, Address, Bday, Program, ConNum; int StudNum, Year; }; //Declaration for the struct. Record Students[50]; //The User-Defined Functions. void Reg(Record Students[]); void bubbleSort(Record Students[],int length); void print(Record Students[]); void search(Record Students[]); //void edit(Record Students[]); //Global Declaration of variables; string CHOICE; int studInt; int length=0; char response; int z=0; //Declaration for the registration function. //int i=0; dahil nag initialize sa case 1..at student number error //Declaration for the search function. string LastName,FirstName, MiddleName; int NumInFile; //Main program. int main() { bool found=false; char choice; do { //The user will choose what to do. cout<<"********************************************************\n" <<"*********************STUDENT RECORD*********************\n" <<"********************************************************\n" <<" [1] => Registration.\n" //Will go to reg() <<" [2] => Search the student record.\n" //Will go to search(); <<" [3] => Quit.\n"; cin.get(choice); if (getline(cin, CHOICE)) // To delete the other unnecesary letters. ; switch(choice) { case '1': { Reg(Students); break; } case '2': { system("CLS"); search(Students); //Students because we have declared that as a identifier of the struct. break; } case '3': { exit(0); } default: { cout<<"your choice is not on the list"<<endl; system("CLS"); return main(); } break; } bubbleSort(Students,length);// This will sort the names of the students. print (Students); cout<<"Want another transaction? (Y/N) "; cin>>choice; //cin.ignore(); toupper(choice); if (toupper(choice)=='Y') { system("CLS"); continue; } found=true; } while (!found); return 0; } void Reg(Record Students[]) // This Function Will Register a student to the group. { int i=0;//where i serves as an index //bool found=false;//will be used for loops later on(will be deleted if we find this useless lateron) ofstream outFile; ifstream inFile; //We declare as an output file the outFile. outFile.open("records.txt", ios::app); //We open. inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/MP 2/MP 2/records.txt"); //LOAD FUNCTION while (!inFile.eof()) { char check; check=inFile.peek(); if (!isdigit(check)) { cout<<"We have found an available slot for you!!"<<endl; break; } system("CLS"); inFile>>Students[i].StudNum ; inFile.ignore(10, '\n'); inFile>>Students[i].FName; inFile.ignore(10, '\n'); inFile>>Students[i].MName; inFile.ignore(10,'\n'); inFile >> Students[i].LName; inFile.ignore(10,'\n'); cout<<"CHECKING FOR AVAILABLE SLOTS...\n\n" <<"Student already registered in slot "<<i+1<<"\n" <<"Looking for available slots\n" <<"Please wait for a few momments....\n";; i++; Sleep(700); } while (i<50) { system("CLS"); cout<<"********************************************************\n" <<"Student's registration form:\n" <<"********************************************************\n\n" <<"You are on slot "<<i+1<<endl<<endl; Students[i].StudNum=2010+i; outFile<<Students[i].StudNum<<endl; cout<<"Enter your First Name: "<<flush; getline(cin,Students[i].FName); outFile<<Students[i].FName<<endl; cout<<"Enter your Middle Name: "; getline(cin,Students[i].MName); outFile<<Students[i].MName<<endl; cout<<"Enter your Last Name: "; getline(cin,Students[i].LName); outFile<<Students[i].LName<<endl; cout<<"Your student number is: "<<Students[i].StudNum<<endl; i++; cout<<"Register another student? (y/n)"; cin>>response; if (response=='y' || response=='Y') { length+=1; cin.ignore();//allows you to further add students... if taken out, program would bug you... bring RAID system("cls"); continue; } else { length+=1; break; } } } void bubbleSort(Record Student[],int length) { string temp1; int iteration; int index; for (iteration=1; iteration<length; iteration++) { for (index = 0; index<length-iteration;index++) { if ((Students[index].LName)>=(Students[index+1].LName)) { temp1=Students[index].LName; Students[index].LName=Students[index+1].LName; Students[index+1].LName=temp1; } } } } void print(Record Students[]) //This function will print the values in the struct Students[] { system("cls");//This will clear the screen. cout<<"********************************************************\n" <<"*********************STUDENT RECORD*********************\n" <<"********************************************************\n"; /*for (int x=0; x<length; x++) { cout<<Students[x].LName<<endl; } */ } void search(Record Students[]) //Search(); { bool found=false; ifstream inFile; inFile.open("C:/Users/Erick/Documents/Visual Studio 2010/Projects/MP 2/MP 2/records.txt"); cout<<"********************************************************\n" <<"*****************Searching for student******************\n" <<"********************************************************\n" <<"Enter the student number: "; cin>>studInt; int ctr=0; while (!inFile.eof() && !found && ctr<3) { inFile>> NumInFile; inFile.ignore(10, '\n'); inFile>> FirstName; inFile.ignore(10,'\n'); inFile>>MiddleName; inFile.ignore(10,'\n'); inFile >> LastName; inFile.ignore(10,'\n'); if (NumInFile==studInt) { cout<<"Yahoo!"<<endl; found=true; continue; } system("CLS"); cout<<"********************************************************\n" <<"*****************Searching for student******************\n" <<"********************************************************\n" <<"\n\n Please wait for a few moments\n as the program searches the record..."<<endl<<endl; Sleep(500); } if (found) { cout<<"The information of the student are the following. "<<endl; cout<<"Full name: "<<LastName<<", "<< FirstName<<' '<<MiddleName<<' '<<endl; } else { cout<<"Sorry, the student ID you entered was not found"<<endl; } system("pause"); //I did'nt include the inFile.close Because there will be a //logic error in search function. }

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ASCII code is binary numbers of 0 and 1 in C++ 2012 Vuhelper 0 2,296 01-04-2012, 10:41 PM
Last Post: Vuhelper
  int x[10]; x[0]= 1; x[1]=2; if following code is executable in C++ 2012 Vuhelper 0 1,949 01-04-2012, 10:17 PM
Last Post: Vuhelper
  array project code c++ 2011 Vuhelper 0 1,297 12-10-2011, 06:32 PM
Last Post: Vuhelper
  factorial in C++ code 2011 Vuhelper 0 970 12-10-2011, 06:31 PM
Last Post: Vuhelper
  stack during function call in C++ 2011 Vuhelper 0 2,042 11-05-2011, 05:05 PM
Last Post: Vuhelper
  What is the Thing Queue? in c++ 2011 Vuhelper 0 1,799 11-05-2011, 05:02 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,741 11-05-2011, 05:01 PM
Last Post: Vuhelper
  How to write a summation in a sequence? C++ 2011-12 Vuhelper 2 1,378 09-19-2011, 04:53 AM
Last Post: Xpert
  GetPixel problem in c++ 2011-12 Vuhelper 0 2,522 09-18-2011, 07:12 PM
Last Post: Vuhelper
  C++ with loop code 2011-12 Vuhelper 0 1,000 09-18-2011, 07:09 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support