Tugas 5 Metode Perancangan Program : Buatlah Program lengkap dengan Pseudocode dan Flowchart


Hallo Blogger, pada kesempatan kali ini saya akan membahas untuk contoh soal dari mata kuliah Metode Perancangan Program.

Saya sudah mengerjakan untuk tugas 5 dari mata kuliah Metode Perancangan Program ini, dan mungkin saja soal ini sama dengan sobat dan sobat bisa mempelajarinya lagi dengan baik.

Berikut adalah contoh soalnya :

Buatlah Program lengkap dengan Pseudocode dan Flowchart untuk menampilkan :
  1. Bilangan Fibonanci
  2. Bilangan Faktorial
  3. Angka bilangan bulat dalam bentuk kalimat, contoh : 32,768 di tampilkan Tiga Puluh Dua Ribu Tujuh Ratus Enam Puluh Delapan Rupiah.

Dan berikut adalah jawaban dari setiap soalnya :

Jawaban soal nomor 1 :

1. Pseudocode

Program Bilangan_Fibonanci {Menentukan bilangan fibonanci}

Deklarasi :

int x = -1, y = 1, z, a, jml 

Deskripsi :

Baca Jumlah Deret
for (a=1;a<=jml;a++){
z=x+y;
cout<<z;
x=z
y=z
cetak deret fibonanci 

Flowchart :


Program :


#include <iostream>
#include <conio.h>
main(){
    int x=-1, y=1, z, a, jml;
    cout<< "Jumlah deret Fibonacci = "; cin>> jml;
    cout<< "Deret Fibonacci = \n";
    for(a=1 ; a<=jml; a++)
    {
        z=x+y;
        cout<< z <<ends;
        x=y;
        y=z;
    }
    cout<< endl;
    getch();
}


Jawaban Soal nomor 2 :

Pseudocode :

Program Bilangan_faktorial (menentukan bilangan faktorial)

Deklarasi :

int bil,n
long int hasil

Deskripsi :

input angka n
for(bil=n; bil>=1; bil--){
hasil = hasil * bil;
cetak hasil

Flow Chart :
 

Program :


#include<iostream>
#include<conio.h>
    int main(){
    
    int bil, n;
    long int hasil;

cout<<"===Mencari Nilai Faktorial===";
cout<<"\n===dari Bilangan Desimal===";
cout<<"\n=============================";
cout<<"\n\nMasukan angka = ";
cin>> n;

hasil=1;
   for(bil=n; bil>=1;bil--){
     hasil=hasil*bil;
}
    cout<<"Hasil Faktorial= "<<hasil<<"\n";
getch();
}


Jawabn soal no 3 :

Pseudocode :


Program bilangan bulat
{ menentukan bilangan bulat dalam kalimat}

deklarasi

void satuan (int x)
void terbilang (long y)


deskripsi

input bilangan
if y <= 11 = satuan
else if y > 11 & y <=19
terbilang = belas
else if y > 20 & y <=99
terbilang = puluh
else if y > 100 & y <=199
terbilang = seratus
else if y > 200 & y <=999
terbilang = ratus
else if y > 1000 & y <=1999
terbilang = seribu
else if y > 2000 & y <=9999
terbilang = ribu
else if y > 1000000
terbilang = juta
cetak terbilang

Flowchart :


Program :


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

void satuan(int x)
{
if (x==1) cout<<" Satu ";
else if (x==2) cout<<" Dua ";
else if (x==3) cout<<" Tiga ";
else if (x==4) cout<<" Empat ";
else if (x==5) cout<<" Lima ";
else if (x==6) cout<<" Enam ";
else if (x==7) cout<<" Tujuh ";
else if (x==8) cout<<" Delapan ";
else if (x==9) cout<<" Sembilan ";
else if (x==10) cout<<" Sepuluh ";
else if (x==11) cout<<" Sebelas ";
}
void terbilang(long y)
{
if (y<=11) satuan(y);
else if ((y>11) && (y<=19))
{
terbilang(y%10);
cout<<"Belas";
}
else if ((y>=20)&&(y<=99))
{
terbilang(y/10);
cout<<"Puluh";
terbilang(y%10);
}
else if ((y>=100)&&(y<=199))
{
cout<<"Seratus";
terbilang(y%100);
}
else if ((y>=200)&&(y<=999))
{
terbilang(y/100);
cout<<"Ratus";
terbilang(y%100);
}
else if ((y>=1000)&&(y<=1999))
{
cout<<"Seribu";
terbilang(y%1000);
}
else if ((y>=2000)&&(y<=9999))
{
terbilang(y/1000);
cout<<"Ribu";
terbilang(y%1000);
}
else if ((y>=10000)&&(y<=99999))
{
terbilang(y/1000);
cout<<"Ribu";
terbilang(y%1000);
}
else if ((y>=100000)&&(y<=999999))
{
terbilang(y/1000);
cout<<"Ribu";
terbilang(y%1000);
}
else if ((y==1000000))
{
terbilang(y/1000000);
cout<<"Juta";
terbilang(y%1000000);
}
else if ((y>1000000))
{
cout<<"error";
}
}
void main()
{
unsigned long nilai;
printf(" \t\t\t Konversi Angka ke Dalam Kata \n");
cout << "\n ~ MASUKKAN BILANGAN [ 1 - 1 JUTA ] : ";
cin >>nilai;
terbilang(nilai);
getch();
}

No comments:

Post a Comment