Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // re4(9).cpp
- /* this program demonstrates the use of structures in structures( complex structures ) */
- /*
- this program has calculates the number of FISH AND MARGINS in the program
- it has a pre-defined density of fish for each ocean( which is of-course random ),
- it prompts the user to enter the name of the ocean and now,
- since we do not expect the user to enter the name in all capital letters or in all small letters,
- we send it down to a function which brings it all down to small letters so that the system can process it with ease,
- now it prompts the user to enter the number of ships that he/she will be sending to fish,
- and also the max-number of fish that each ship can catch.
- it then calculates the total number of fish that he will be getting back.
- the program will also prompt the user, the avg.rate for each fish and calculates the total income.
- it will further prompt the user about the avg.cost per ship and then calculates the net profit
- for the total expedition.
- this program makes use of complex structures and default arguments for functions.
- */
- /* this file hasn't yet been added to the revamp-4 project, so it's totally anonymous
- therefore maintain caution */
- #include<iostream>
- const int fish_net=35;
- using namespace std;
- struct ST_fish{int fsii,fnii; double ocean,ftii,total_fish;}; // structure ' 1 '
- struct ST_sail{int sailorno; double sailor_salary;}; // structure ' 2 '
- class crcpara{ // this is a class of menu related functions and mainly outputs
- public:
- crcpara(void){}; ~crcpara(void){};
- void chooser_disp(){
- cout << "\t no: name of the ocean \n";
- cout << "\t 1 Indian ocean \n";
- cout << "\t 2 pacific ocean \n";
- cout << "\t 3 atlantic ocean \n";
- cout << "\t 4 articic ocean \n";};
- double chooser_cho(int lock){
- switch(lock){
- case 1:
- {return 12.55;break;}
- case 2:
- {return 11.67;break;}
- case 3:
- {return 10.34;break;}
- case 4:
- {return 9.43;break;}
- default:
- {cout << " do not counterflirt with the program "<< endl;break;}};
- }
- // confirmation function
- };
- class crcpuru{ // this is a class of caluclaton related functions
- private:
- int fsi,fni;double fti;
- public:
- crcpuru(int a,int b,double c){fsi=a;fni=b;fti=c;}; ~crcpuru(void){};// constructor, deconstructor
- /* NOTE unused deconstructors may sometimes flag errors */
- double fish_finder(int fsi,int fni,double fti) // func
- {double temp1;
- temp1=fni*fti*fish_net*fsi; // will calculate the number of fish that comes out of each ship in one hour
- return temp1;};
- char onceanfinder(int loc){
- if (loc==12.55){return " India Ocean";}
- else if (loc==11.67){return " Pacific Ocean";}
- else if (loc==10.34){return " Atlantic Ocean ";}
- else if (loc==9.43) {return " Arctic Ocean ";}
- else {return "error";};
- };
- };
- class decco{ // this class contains decoration related functions
- public:
- decco(void){}; ~decco(void){};
- char baline(int a, char b)
- {
- for(int kk=0;kk<=a;kk++){cout<<b;}
- };};
- int main()
- {
- int damn=0; //' 1 ' automatic variable
- crcpara plm; decco dec; // object
- crcpuru coco(0,0,0); // object
- /* NOTE objects must be declared for constructors */
- ST_fish fish={0,0,0,0,0}; ST_sail sail={0,0}; // structure's declaration
- cout << " hello, this program is for enterpreuners and NOT for kids, \n so maintain caution "<<endl;
- dec.baline(64,'_');
- cout <<endl<< " please choose the ocean which your going to fish in "<<endl;
- plm.chooser_disp();
- cin >> damn;
- fish.ocean=plm.chooser_cho(damn);
- cout<<" please enter the number of ships you will be sending to fish "<<endl;
- cin>>fish.fsii;
- cout<<" please enter the number of fish-nets that each ship can hold \n on board at a time "<<endl;
- cin>>fish.fnii;
- cout<<" remember each fish net can capture only 35 fish to the max, "<<endl;
- cout<<" so the program will calclate taking into consideration only that value " <<endl;
- cout<<" please enter the number of hours your are planning to station \n your ships at the spot ";
- cin>>fish.ftii;
- fish.total_fish=coco.fish_finder(fish.fsii,fish.fnii,fish.ftii);
- cout<<" please enter the total number of sailor on each ship "<<endl;
- cin>>sail.sailorno;
- cout<<" please enter the ammount of money that you will be paying for each sailor "<<endl;
- cin>>sail.sailor_salary;
- // plm.confirfish(fish);
- cin.ignore();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement