Pages

Rabu, 13 April 2011

luas dan volum

#include <cstdlib>
#include <iostream>

using namespace std;

class hendy{
      friend istream& operator>>(istream&, hendy&);
      friend ostream& operator<<(ostream&, hendy&);
     
      public:
             hendy();
             void luas_lingkaran(){
                  phi=3.14;
                  luas=phi*r*r;};
             void volume_bola(){
                  phi=3.14;
                  volume=(3*phi*r*r*r)/4;};
            
      private:
              float r;
              float phi;
              float luas;
              float volume;
      };
      hendy::hendy(){
             cout<<"menghitung luas lingkaran dan volume dengan inputan jari - jari\n"<<endl;
             }
            
istream& operator>>(istream& in, hendy& mlebu){
         cout<<"masukkan nilai jari - jari : ";
         in>>mlebu.r;
         return in;
         }
        
ostream& operator<<(ostream& out, hendy& metu){
         out<<"luas lingkaran = "<<metu.luas<<endl;
         out<<"volume bola    = "<<metu.volume<<endl;
         return out;
         }
     

int main(int argc, char *argv[])
{
    usman hendy;
    cin>>hendy;
    hendy.luas_lingkaran();
    hendy.volume_bola();
    cout<<hendy;
   
    system("PAUSE");
    return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>

using namespace std;

class hendy{
      friend istream& operator>>(istream&, hendy&);
      friend ostream& operator<<(ostream&, hendy&);
     
      public:
             hendy();
             void luas_lingkaran(){
                  phi=3.14;
                  luas=phi*r*r;};
             void volume_bola(){
                  phi=3.14;
                  volume=(3*phi*r*r*r)/4;};
            
      private:
              float r;
              float phi;
              float luas;
              float volume;
      };
     
hendy::hendy(){
             cout<<"menghitung luas lingkaran dan volume dengan inputan jari - jari\n"<<endl;
             }
            
istream& operator>>(istream& in, dyas& mlebu){
         cout<<"masukkan nilai jari - jari : ";
         in>>mlebu.r;
         return in;
         }
        
ostream& operator<<(ostream& out, dyas& metu){
         out<<"luas lingkaran = "<<metu.luas<<endl;
         out<<"volume bola    = "<<metu.volume<<endl;
         return out;
         }
     

int main(int argc, char *argv[])
{
    usman hendy;
    cin>>hendy;
    hendy.luas_lingkaran();
    hendy.volume_bola();
    cout<<heru;
   
    system("PAUSE");
    return EXIT_SUCCESS;
}

0 komentar:

Posting Komentar