Solution to Lobatsi House of Brokers (LHB) is an organization responsible for keeping track of all brokers … - Sikademy
Author Image

Archangel Macsika

Lobatsi House of Brokers (LHB) is an organization responsible for keeping track of all brokers nationwide. A broker acts as a middle man between a buyer and a seller; a buyer communicates with a broker for arrangements of trade with the seller. LHB only works with brokers involved in the trading of houses and sites. The organization ensures that brokers follow certain rules to stay in business. All brokers, sellers, sites, houses and buyers must be registered in the system. The system will then maintain information about the following data items, broker, seller, buyer, site and house. Broker has the following attributes: ● Br code, BR name, Maximum sale made, list of items sold and Number of items sold . Seller has the following attributes: ● Registration number, Name, List of items sold and Accumulative monthly sale. Buyer has the following attributes: ● Registration number, Name, List of items bought, Accumulative monthly purchases and Accumulative discount. Site has the following attributes: ● Property code, Description, Type, Price. House has the following attributes: ● Property code, Description, Type, Price. A broker is identified by the Br code. Each broker is allowed to make a maximum of 20 sales per month. Monthly sales of all brokers are stored in the following format. The table below assumes that we have 2 brokers. The first broker has Br code of 0001 and has made six sales, the second broker has Br code of 0002 and has made three sales, the third broker has Br code of 0003 and has made one sale and the fourth broker has Br code of 0004 and has made four sales.

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question


#include <iostream> #include<string> #include <fstream> using namespace std; //structer declaration struct property{ int property_code; string description;////either house or site string type;//residential or commercial , if house, family ,mansion or apartment int price; }; struct broker{ string Brcode, Brname; int maxsale; property sales[20]; int number_sales;//should not be more than hundred }; struct seller{ int regnumber; string name; property sales[20]; int number_sales; int accumulative_m_sale; }; struct buyer { int reg_number; string name ; property purchases[20]; int accumulative_m_purchases; int number;//number of purchases int accumulative_m_discounts; }; //prototype buyer buyers[20]; seller sellers[20]; broker brokers[20]; int num_brokers=0;//keeps a the number of brokers int num_sellers=0; int num_buyers=0; //report function void tabulate(){ fstream copy; copy.open("brokers.txt", fstream::app); if(copy.is_open()){ for(int i=0;i<num_brokers;i++){ copy<<"BROKER : "; copy<<brokers[i].Brcode; copy<<" | "; for(int j=0;i<brokers[i].number_sales;j++){ copy<<brokers[i].sales[j].description; copy<<" "; copy<<brokers[i].sales[j].type; copy<<" "; copy<<brokers[i].sales[j].price; copy<<" | "; } copy<<"\n "; } } } //acummulation function for seller int accumulative_msales(seller name){ int sum=0; for (int i=0;i<name.number_sales;i++){ sum=sum+name.sales[i].price; } return sum; } //accumulation function for buyer int accumulative_mpurchases(buyer name){ int sum=0; for (int i=0;i<name.number;i++){ sum=sum+name.purchases[i].price; } return sum; } //discount function int accumulative_mdiscount(buyer name){ int sum=0; for (int i=0;i<name.number;i++){ sum=sum+name.purchases[i].price; } int discount=(sum*(1.2/100)); return discount; } void add(broker name1, seller name2, buyer name3){ //store each in their individual respective lists if (num_brokers<20){ brokers[num_brokers].Brcode=name1.Brcode; brokers[num_brokers].Brname=name1.Brname; brokers[num_brokers].maxsale=name1.maxsale; brokers[num_brokers].number_sales=name1.number_sales; for(int i=0;i<brokers[num_brokers].number_sales;i++){ brokers[num_brokers].sales[i]=name1.sales[i]; } num_brokers++; } else{ cout<<"list of brokers is full\n"; //must be less than 20 } if (num_sellers<20){ sellers[num_sellers].accumulative_m_sale=name2.accumulative_m_sale; sellers[num_sellers].name=name2.name; sellers[num_sellers].number_sales=name2.number_sales; sellers[num_sellers].regnumber=name2.regnumber; for(int i=0;i<sellers[num_sellers].number_sales;i++){ sellers[num_sellers].sales[i]=name2.sales[i]; } num_sellers++; } else{ cout<<"list of sellers is full\n"; } if (num_buyers<20){ buyers[num_buyers].accumulative_m_discounts=name3.accumulative_m_discounts; buyers[num_buyers].accumulative_m_purchases=name3.accumulative_m_purchases; buyers[num_buyers].name=name3.name; buyers[num_buyers].number=name3.number; for(int i=0;i<buyers[num_buyers].number;i++){ buyers[num_buyers].purchases[i]=name3.purchases[i]; } buyers[num_buyers].reg_number=name3.reg_number; num_buyers++; } else{ cout<<"list of buyers is full\n"; } } void transaction(){//this transaction may be a transaction for a house or site property name; num_brokers++; if (brokers[num_brokers].number_sales<brokers[num_brokers].maxsale){ cout<<"ENTER THE PROPETY DESCRIPTION , HOUSE or SITE : \n"; cin>>name.description; cout<<"ENTER THE PROPERTY TYPE e.g whether apartment or mansion or family if house or use for the site i.e commercial \n"; cin>>name.type; cout<<"ENTER THE PRICE :] \n"; cin>>name.price; cout<<"ENTER THE PROPERTY CODE :\n"; cin>>name.property_code; brokers[num_brokers].number_sales++; brokers[num_brokers].sales[num_sellers]=name; } } int max_sale(){ int max=0; for(int k=0;k<num_brokers;k++){ for(int i=0;i<brokers[k].number_sales;k++){ if(brokers[k].sales[i].price>=max){ max=brokers[k].sales[i].price; } } } return max; } // void display_reg(){ int index; int code ; cout<<"ENTER THE SITE OR HOUSE code name FOR SEELER AND BUYER \n"; cin>>code ;//we will use the fact that the index of the property sales in brokers matches that of sellers and buyers corresponding for(int i=0;i<num_brokers;i++){ for(int j=0;j<brokers[i].number_sales;j++){ if (brokers[i].sales[j].property_code==code){ index=j; } } } cout<<"the sellers and buyer reg numbers for code "<<code<<" are "<<sellers[index].regnumber<<"seller "<<buyers[index].reg_number<<"buyer\n"; } //swap function void swap(property name1, property name2){ string temporary ; temporary =name1.description; name1.description=name2.description; name2.description=temporary; } void list_properties(){ string temp; int t; for(int i=0;i<num_brokers;i++){ for (int k=0;brokers[i].number_sales;k++){ for(int j=k+1;j<brokers[i].number_sales;j++){ if(brokers[i].sales[k].price<brokers[i].sales[j].price){ temp=brokers[i].sales[k].description; brokers[i].sales[k].description=brokers[i].sales[j].description; brokers[i].sales[j].description=temp; t=brokers[i].sales[k].price; brokers[i].sales[k].price=brokers[i].sales[j].price; brokers[i].sales[j].price=t; t=brokers[i].sales[k].property_code; brokers[i].sales[k].property_code=brokers[i].sales[j].property_code; brokers[i].sales[j].property_code=t; temp=brokers[i].sales[k].type; brokers[i].sales[k].type=brokers[i].sales[j].type; brokers[i].sales[j].type=temp; } } } } for(int i=0;i<num_brokers;i++){ for (int k=0;k<brokers[i].number_sales;k++){ cout<<"the sorted list in descending order is :\n"; cout<<brokers[i].sales[k].property_code<<"code "; cout<<brokers[i].sales[k].type<<"type "; cout<<brokers[i].sales[k].price<<"price \n"; } } } //monthly report function to txt file void monthly_report(){ fstream copy; copy.open("report.txt", fstream::app); if(copy.is_open()){ for(int i=0;i<num_brokers;i++){ copy<<"BROKER : "; copy<<brokers[i].Brcode; copy<<" | "; copy<<"seller :"; copy<<sellers[i].name; copy<<" | "; copy<<"buyer :"; copy<<buyers[i].name; copy<<" | "; for(int j=0;i<brokers[i].number_sales;j++){ copy<<brokers[i].sales[j].description; copy<<" "; copy<<brokers[i].sales[j].type; copy<<" "; copy<<brokers[i].sales[j].price; copy<<" | "; } copy<<"\n "; } } } int drive(){ //drive menu property name1, name2; broker name3; seller name4; buyer name5; int n, choice; cout<<"*************************************************\n"; cout<<"\t\t MENU \t\t\t\n"; cout<<"*************************************************\n\n"; cout << "1. Insert Data of brokers,sellers and buyers \n"; //adddata cout << "2. Insert Data of sites and houses \n"; //siteshouses cout << "3. Search for highest maximum sale of broker \n"; //maximum cout << "4. Search a certain house's registration of seller and buyer \n"; //registration cout << "5. Swap description of two properties\n"; //swap cout << "6. List all properties in descending order of price\n"; //descendingorder cout << "7. Generate monthly reports of broker, sellers, buyers, sites and houses \n"; //report cout << "8. Exit \n"; //exit cout << "\n\nWhat would you like to do from the above menu: "; cin >> choice; switch (choice){ case 1: add(name3, name4,name5); break; case 2: transaction(); break; case 3: max_sale(); break; case 4: display_reg(); break; case 5: swap(name1, name2); break; case 6: list_properties(); break; case 7: monthly_report(); break; } while(choice !=8); cout<<"Exiting...Blessed day!"; } int main() { system("color 1F"); cout<<"\tLesotho House of Brokers (LHB)\n"; cout<<"\ttrack of all brokers nationwide\n\n"; drive(); return 0; }

Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1092-qpid-88