diff --git a/Hostel_Accomodation_System/Hostel.txt b/Hostel_Accomodation_System/Hostel.txt new file mode 100644 index 0000000..7d8e439 --- /dev/null +++ b/Hostel_Accomodation_System/Hostel.txt @@ -0,0 +1 @@ + Gomukh Hostel : 16500 :2 diff --git a/Hostel_Accomodation_System/Hostel_Accomodation_System.cpp b/Hostel_Accomodation_System/Hostel_Accomodation_System.cpp new file mode 100644 index 0000000..4f4dada --- /dev/null +++ b/Hostel_Accomodation_System/Hostel_Accomodation_System.cpp @@ -0,0 +1,160 @@ +#include +#include +#include +#include +using namespace std; + +class Hostel{ + private: + string Name; + int Rent, Bed; + public: + Hostel(string name, int rent, int bed) + { + Name = name; + Rent = rent; + Bed = bed; + } + + string getName() + { + return Name; + } + int getRent() + { + return Rent; + } + int getBed() + { + return Bed; + } + + void reserve() + { + ifstream in("C:/Users/priya/Documents/HAS/Hostel.txt"); + ofstream out("C:/Users/priya/Documents/HAS/Hostel Temp.txt"); + + string line; + while(getline(in, line)) + { + int pos = line.find("Gomukh Hostel"); + if(pos != string::npos) + { + int bed = Bed -1; + Bed = bed; + + stringstream ss; + ss << bed; + string strBed = ss.str(); + + int bedPos = line.find_last_of(':'); + line.replace(bedPos+1, string::npos, strBed); + } + out<> val; + + if(val == 1) + { + system("cls"); + string name, rollNo, address; + + cout<<"\tEnter name of Student : "; + cin >> name; + s.setName(name); + + cout<<"\tEnter RollNo of the Student : "; + cin >> rollNo; + s.setRollNo(rollNo); + + cout<<"\tEnter Address of the Student : "; + cin >> address; + s.setRollNo(address); + + if(h.getBed() > 0){ + + h.reserve(); + } + else if(h.getBed() == 0){ + + cout<<"\tSorry, Bed not available"<