THOUSANDS OF FREE BLOGGER TEMPLATES

Minggu, 24 April 2011

MENGHITUNG VOLUME BOLA

Algoritma Menghitung Volume Bola
{membaca masukkan r, lalu program menuliskan hasil v (volume bola)}


DEKLARASI
r  = float (input)
v  = float      (output)


DESKRIPSI
Read (r)
v<– (4*3.14*(r*r*r))/3
Write (v)



Program

#include <iostream.h>
#include <conio.h>

class bola{
public:
    bola();
protected:
    float r;
};

bola::bola(){
      cout<<"\n";
}

class volume : public bola{
public:
  void volume_bola(float);
private:
  float V;
};

void volume::volume_bola(float p){
      r = p;
      V = (4*3.14*(r*r*r))/3;
      cout<<" Volume Bola = "<<V<<endl;
}

int main(int argc, char *argv[])
{
      bola x;
      float i;
      cout<<" Masukkan r  = ";
      cin>>i;
      volume y;
      y.volume_bola(i);

    getch ();
    return 0;
}

0 komentar: