pert 8 soal 2

Tugas 8-2

 

Tentukan jenis kohesi dan kopling, untuk latihan nomor 2 dan 3 , hal 124

Bab. Communication between modules

dari buku Simple Program Design, edisi ke dua.

 

No 2.

 

Kohesi Functional

void sort()

{

int temp;

for(int i=0;i<4;i++)

{

for(int j=3;j>i;j–)

{

if(number[i]>number[j])

{

temp=number[i];

number[i]=number[j];

number[j]=temp;

}

}

}

}

 

Kopling Data

int main()

{

for(int i=0;i<4;i++)

{

cout<<”Masukkan Number ke-”<<(i+1)<<” : “;

cin>>number[i]; cin.sync(); cin.clear();

}

sort();

cout<<”Maka acsending nya adalah”<<endl;

for(int i=0;i<4;i++)

{

cout<<number[i]<<” “;

}

cin.get();

return 0;

 

}

 

No 3

Kopling Functional

void input(int &tahun)

{

do{

cout<<”Masukkan tahun [4 digit] : “;

cin>>tahun; cin.sync();cin.clear();

if(tahun<1000||tahun>9999)

cout<<”inputan lebih dari 4 digit atau lebih kecil dari 4 digit”<<endl;

}while(tahun<1000||tahun>9999);

}

 

Kopling Kontrol

int main()

{

int tahun;

input(tahun);

if(tahun%4==0) cout<<”ini tahun kabisat”;

else cout<<”ini bukan tahun kabisat”;

cin.get();

}

 

Explore posts in the same categories: MPP

2 Komentar pada “pert 8 soal 2”

  1. krazykoreankyle Berkata

    i love pandas


Tinggalkan Balasan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Ubah )

Twitter picture

You are commenting using your Twitter account. Log Out / Ubah )

Facebook photo

You are commenting using your Facebook account. Log Out / Ubah )

Connecting to %s


Ikuti

Get every new post delivered to your Inbox.