I have to create one real estate project in C++ using structure,arrays,functions nad switch case.?
-
I tried to get output so many times.but i dont get. 1.i have one file name properties.txt using case 1 user can list all the properties in the file case 2 search property by price case 3 user can add property by enter street address,suburb,price case 4 saveproperties i create all the functions but it is not ask the user to enter file name and switch case is not working,no functions is working. my program like this::: #include<iostream> #include<fstream> #include<string> using namespace std; const int MAX = 50; struct property { string streetaddress; string suburb; double price; }; void readFile(property realEstate[],int &numOfProperties); void listAll(property realEstate[],int numOfProperties); void search(property realEstate[],int numOfProperty); void addProperty(property realestate[],int &numOfProperties); void saveProperties(property realEstate[],int numOfProperties); int main() { char chMenu = 0; int numOfProperties = 0; property realEstate[MAX] = {" "," ",0.0}; readFile(realEstate,numOfProperties); do { cout<<"CPProperty - Menu :"<<endl; cout<<"1 - List all properties"<<endl; cout<<"2 - Property search"<<endl; cout<<"3 - Add a property"<<endl; cout<<"4 - Save property list"<<endl; cout<<"5 - Exit"<<endl<<endl; cout<<"Please enter option :"<<endl; cin>>chMenu; switch(chMenu) { case 1: { listAll(realEstate,numOfProperties)… break; } case 2: { search(realEstate,numOfProperties);… break; } case 3: { addProperty(realEstate,numOfPropert… break; } case 4: { saveProperties(realEstate,numOfProp… break; } case 5: { cout<<"Thank you for using CPProperty"<<endl; break; } default: cout<<"Illegal menu option"; } }while(chMenu>5); system("pause"); return 0; } void readFile(property properties[],int &numOfProperties) { //string fileName; cout<<"Enter property filename : "; cin>>inFile; cin.ignore (INT_MAX, '\n'); ifstream inFile("properties.txt"); if (inFile.is_open()) // or if (fin.is_open() == false) { while(!inFile.eof()) { getline(inFile,realEstate[numOfPrope… //inFile.getline(realEstate[numOfPro… cout<<"Enter the Address : "; /*cout<<"Suburb Name : "; inFile.getline(realEstate[numOfPrope… cout<<" Price : $"; cin >> realEstate[numOfProperties].price;*/ inFile.ignore(INT_MAX, '\n'); numOfProperties++; } inFile.close(); } else cout<<"File does not exist"; } void listAll(property realEstate[],int numOfProperties) { for(int i=0;i<numOfProperties;i++) { cout << realEstate[i].price; cout << realEstate[i].streetaddress; cout << realEstate[i].suburb; } } void search(property realEstate[],int numOfProperty) { int temp; cout<<"Please enter the price limit: "; cin>>temp; for(int i=0;i<numOfProperty;i++) { if(realEstate.price[]<temp) { cout << realEstate[i].price; cout << realEstate[i].streetaddress; cout << realEstate[i].suburb; } } } void addProperty(property realEstate[],int &numOfProperties) { int price = 0; cout<<"Enter Address :" ; getline(cin, realEstate[numOfproperties].streetaddres… cout<<"Enter Suburb :"; getline(cin, realEstate[numOfproperties].suburb); cout<<"Enter Price :"; cin>>price; cout<<"Property:"<<realEstate[numOfp… } void saveProperties(property realEstate[],int numOfProperties) { string filename=" "; cout<<"Enter filename: "; cin>>filename; ofstream fout; fout.open(filename.c_str()); fout.close(); for(int i=0;i<numOfProperties;i++) { fout << realEstate[i].price; fout << realEstate[i].streetaddress; fout << realEstate[i].suburb; } }
-
Answer:
chMenu should be a integer, not a char.
Jignesh P at Yahoo! Answers Visit the source
Related Q & A:
- Should I use a code repository if I am the only one working on a project?Best solution by Programmers
- How can I become a real estate appraiser?Best solution by Yahoo! Answers
- How do I get a license to sell real estate internationally?Best solution by Yahoo! Answers
- How do I become a real estate paralegal?Best solution by collegemouse.com
- What exactly do I need to do to get my California real estate license?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.