18 Maret 2017

Postest 2 (Menghitung daerah yang diarsir)

Assalmuallaikum wr. wb
Hallo bertemu lagi dengan feny disini. Kali ini aku akan memposting tugas postest yang menggunakan Raptor Flowchart mode Object-Oriented.
Langsung saja ya...


Untuk program nomor 1 ada dibawah ini :

Pertama masukkan UML dengan memilih New Method dan New Field

 

Kemudian masukkan main, main disini berisi rumusan persoalan diatas 

 Dan masukkan rumus-rumus pemanggil yang telah diinputkan sebelumnya.




 * Hasil outputnya jika dimasukkan jari-jari = 3

.

* Program Menggunakan C++ :

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class hasil{
    private:
        float persegi();
        float lingkaran();
        float arsir();
    public:
        float phi,lp,ll,arsiran,jari;
};
float persegi(int a){
    float hasil;
    hasil=a*a;
    return hasil;
}

float lingkaran(int a,float phi){
    float hasil;
    hasil=phi*a*a;
    return hasil;
}

float arsir(float pers,float ling){
    float hasil;
    hasil=pers-ling;
    return hasil;
}
int main(int argc, char** argv) {

    hasil x;
    int s;
x.phi=3.14;
    cout<<"Masukkan sisi :";
    cin>>s;
    x.jari=0.5*s;
    x.lp=persegi(s);
    x.ll=lingkaran(x.jari,x.phi);
    x.arsiran=arsir(x.lp,x.ll);
   
    cout<<endl<<"Hasil luas persegi : "<<x.lp<<endl;
    cout<<"Hasil luas lingkaran : "<<x.ll<<endl;
    cout<<"Hasil Arsiran : "<<x.arsiran;
   
    return 0;
}

*Hasil Outputnya bila dimasukkan jari-jarinya 4 dan tinggi 10 :

 * Untuk kasus nomor 2 :
Program Raptor :
 
Program C++ :
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class hasil{
    private:
        float tabung();
        float bola();
        float arsir();
    public:
        float phi,vt,vb,arsiran;
};
float tabung(int a,int b,float phi){
    float hasil;
    hasil=phi*a*a*b;
    return hasil;
}

float bola(int a,float phi){
    float hasil;
    hasil=phi*a*a*a*4/3;
    return hasil;
}

float arsir(float tb,float bl){
    float hasil;
    hasil=tb-bl;
    return hasil;
}
int main(int argc, char** argv) {

    hasil x;
    int r,t;
x.phi=3.14;
    cout<<"Masukkan jari-jari :";
    cin>>r;
    cout<<"Masukkan Tinggi : ";
    cin>>t;
   
    x.vt=tabung(r,t,x.phi);
    x.vb=bola(r,x.phi);
    x.arsiran=arsir(x.vt,x.vb);
   
    cout<<endl<<"Hasil Volume Tabung : "<<x.vt<<endl;
    cout<<"Hasil Volume Bola : "<<x.vb<<endl;
    cout<<"Hasil Arsiran : "<<x.arsiran;
   
    return 0;
}



*Hasil outputnya adalah bila dimasukkan jari-jari 3 dan tingginya 6 


Sekian dan Terimakasih

Wassalamuallaikum

0 komentar:

Posting Komentar