Advertisement
udaykumar1997

re4(works).cpp

Sep 22nd, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.29 KB | None | 0 0
  1. // re4(9).cpp
  2. /* this program demonstrates the use of structures in structures( complex structures ) */
  3. /*
  4. this program has calculates the number of FISH AND MARGINS in the program
  5. it has a pre-defined density of fish for each ocean( which is of-course random ),
  6. it prompts the user to enter the name of the ocean and now,
  7. since we do not expect the user to enter the name in all capital letters or in all small letters,
  8. we send it down to a function which brings it all down to small letters so that the system can process it with ease,
  9. now it prompts the user to enter the number of ships that he/she will be sending to fish,
  10. and also the max-number of fish that each ship can catch.
  11. it then calculates the total number of fish that he will be getting back.
  12. the program will also prompt the user, the avg.rate for each fish and calculates the total income.
  13. it will further prompt the user about the avg.cost per ship and then calculates the net profit
  14. for the total expedition.
  15. this program makes use of complex structures and default arguments for functions.
  16. */
  17. /* this file hasn't yet been added to the revamp-4 project, so it's totally anonymous
  18.    therefore maintain caution */
  19.  
  20. #include<iostream>
  21. const int fish_net=35;
  22.  
  23. using namespace std;
  24.  
  25.      
  26.       struct ST_fish{int fsii,fnii;       double ocean,ftii,total_fish;};        // structure ' 1 '
  27.       struct ST_sail{int sailorno; double sailor_salary;};                       // structure ' 2 '
  28.      
  29. class crcpara{                                                           // this is a class of menu related functions and mainly outputs
  30. public:
  31.        crcpara(void){}; ~crcpara(void){};
  32.        void chooser_disp(){
  33.            cout << "\t no:      name of the ocean \n";
  34.            cout << "\t 1        Indian ocean \n";
  35.            cout << "\t 2        pacific ocean \n";
  36.            cout << "\t 3        atlantic ocean \n";
  37.            cout << "\t 4        articic ocean \n";};
  38.        double chooser_cho(int lock){
  39.            switch(lock){
  40.            case 1:
  41.                 {return 12.55;break;}
  42.            case 2:
  43.                 {return 11.67;break;}
  44.            case 3:
  45.                 {return 10.34;break;}
  46.            case 4:
  47.                 {return 9.43;break;}
  48.            default:
  49.                 {cout << " do not counterflirt with the program "<< endl;break;}};
  50.        }
  51.                                                   // confirmation function
  52. };
  53.  
  54. class crcpuru{                                                      // this is a class of caluclaton related functions
  55.       private:
  56.               int fsi,fni;double fti;
  57.       public:
  58.              crcpuru(int a,int b,double c){fsi=a;fni=b;fti=c;};  ~crcpuru(void){};// constructor, deconstructor
  59. /* NOTE unused deconstructors may sometimes flag errors */
  60.              double fish_finder(int fsi,int fni,double fti)                            // func
  61.              {double temp1;
  62.              temp1=fni*fti*fish_net*fsi; // will calculate the number of fish that comes out of each ship in one hour
  63.              return temp1;};
  64.              
  65.              char onceanfinder(int loc){
  66.                   if (loc==12.55){return " India Ocean";}
  67.                   else if (loc==11.67){return " Pacific Ocean";}
  68.                   else if (loc==10.34){return " Atlantic Ocean ";}
  69.                   else if (loc==9.43) {return " Arctic Ocean ";}
  70.                   else {return "error";};
  71.              };
  72. };
  73.  
  74. class decco{                                                       // this class contains decoration related functions
  75.       public:
  76.              decco(void){};       ~decco(void){};
  77.       char baline(int a, char b)
  78.           {
  79.              for(int kk=0;kk<=a;kk++){cout<<b;}
  80.           };};
  81.  
  82. int main()
  83. {
  84.     int damn=0;                                                               //' 1 ' automatic variable
  85.     crcpara plm; decco dec;                                                   // object
  86.     crcpuru coco(0,0,0);                                                      // object
  87. /* NOTE objects must be declared for constructors */
  88.     ST_fish fish={0,0,0,0,0}; ST_sail sail={0,0};                             // structure's declaration
  89.     cout << " hello, this program is for enterpreuners and NOT for kids, \n so maintain caution "<<endl;
  90.     dec.baline(64,'_');
  91.     cout <<endl<< " please choose the ocean which your going to fish in "<<endl;
  92.     plm.chooser_disp();
  93.     cin >> damn;
  94.     fish.ocean=plm.chooser_cho(damn);
  95.     cout<<" please enter the number of ships you will be sending to fish "<<endl;
  96.     cin>>fish.fsii;
  97.     cout<<" please enter the number of fish-nets that each ship can hold \n on board at a time "<<endl;
  98.     cin>>fish.fnii;
  99.     cout<<" remember each fish net can capture only 35 fish to the max, "<<endl;
  100.     cout<<" so the program will calclate taking into consideration only that value " <<endl;
  101.     cout<<" please enter the number of hours your are planning to station \n your ships at the spot ";
  102.     cin>>fish.ftii;
  103.     fish.total_fish=coco.fish_finder(fish.fsii,fish.fnii,fish.ftii);
  104.     cout<<" please enter the total number of sailor on each ship "<<endl;
  105.     cin>>sail.sailorno;
  106.     cout<<" please enter the ammount of money that you will be paying for each sailor "<<endl;
  107.     cin>>sail.sailor_salary;
  108.     //  plm.confirfish(fish);
  109.     cin.ignore();
  110.     cin.get();
  111.     return 0;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement