suparty beauty

suparty beauty

Sabtu, 16 April 2011

tugas menghitung nilai dan luas lingkaran serta volume bola

nim : 10018036
kl s : b 





    Menghitung Luas Lingkaran dan Volume Bola
dengan menggunakan program Dev  C++
#include <cstdlib>        
#include <iostream>
#include <math.h>
using namespace std;

const float phi=3.14;

class bola
{
public:

void Bola ();
void volume ();

private:
int r;
float jumlah;


};

void bola::Bola()
{
cout<<endl;
cout<<"Menghitung Luas lingkaran"<<endl;
cout<<"masukkan Jari-Jari: "; cin>>r;
jumlah = phi*r*r;
cout<<"Luas lingkaran Adalah: "<<jumlah<<endl;
}

void bola::volume ()
{
cout<<endl;
cout<<"Menghitung Volume Bola"<<endl;
cout<<"Masukkan Jari-jari bola: "; cin>>r;
jumlah=phi*r*r*r*3/4;
cout<<"Volume Bola Adalah: "<<jumlah<<endl;
}

int main(int argc, char *argv[])
{
    char pilih;
bola bol;
bola vol;

label:

cout<<"Menghitung Luas Lingkaran dan volume Bola"<<endl;
cout<<" 1. Menghitung Luas Lingkaran"<<endl;
cout<<" 2. Menghitung Volume Bola "<<endl;
cout<<" Pilih Menu Yang Di inginkan: ";
cin>>pilih;
    switch (pilih)
{
       case '1' : bol.Bola(); break;
       case '2' : vol.volume(); break;
       default  : cout<<"Pilih kembali"<<endl; goto label; break;
}
   
    system("PAUSE");
    return EXIT_SUCCESS;
}

 

Tidak ada komentar:

Posting Komentar