TUGAS PERTEMUAN KE-3

 

Soal 

      1. Buatlah program untuk menampilkan  unsur dan melakukan proses sbb menu ;

                           A. menghitung volume kubus V= sxsxs
                           B. menghitung luas lingkaran L= 22/7 x r x r  
                           C. menghitung volume silinder V = 22/7 x r x r x t
                           pilihan user (1~3) ;

        2. buat program yang menerima input sebuah angka positif, kemudian menampilkan angka               genap 0 sd angka tsb.

Jawab

 1. PROGRAM PENGHITUNGAN RUMUS

gambar 1 contoh programnya

 SCRIPTNYA :

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
 void rumus()
 { }
 main()
{
    int a;

cout<<"\t|    NAMA     : WAHYU NUGROHO INDRAWINATA         |"<<endl;
cout<<"\t|    NIM      : TI-111036                         |"<<endl;
cout<<"\t|    M.K      : Pemograman C++ (Tugas)            |"<<endl;
cout<<"\t|    Semester : III                               |"<<endl;
cout<<"\t|  Membuat program untuk menghitung rumus-rumus   |"<<endl<<endl;
menu:
    cout<<"1. MENGHITUNG VOLUME KUBUS "<<endl;
    cout<<"2. MENGHITUNG LUAS LINGKARAN "<<endl;
    cout<<"3. MENGHITUNG VOLUME SILINDER "<<endl;
    cout<<"4. KELUAR PROGRAM "<<endl;
    cout<<"\n";
     cout<<"SILIHKAN PILIH PILIHAN ANDA(1-4): ";
cin>>a;
 if (a==1)
goto kubus;
else if(a==2)
goto lingkaran;
else if(a==3)
goto selinder;
else if(a==4)
goto exit;
else
cout<<"PILIHAN ANDA TIDAK TERSEDIA OLEH SISTEM \n"<<"SILAHKAN ENTER DAN COBA LAGI";
getch();
goto menu;


kubus:
    {
        int VK,s;
        cout<<"[VOLUME KUBUS]"<<endl;
        cout<<"masukkan panjang sisi kubusnya? ";
        cin>>s;
        VK=s*s*s;
        cout<<"---------------------------"<<endl;
        cout<<"Rumus Volume Kubus = s*s*s "<<endl;
        cout<<"---------------------------"<<endl;
        cout<<"diketahui : "<<endl;
        cout<<"sisi kubus (s) = "<<s<<endl;
        cout<<"---------------------------"<<endl;
        cout<<"JAWAB : "<<endl;
        cout<<"V="<<s;
        cout<<"*"<<s;
        cout<<"*"<<s;
        cout<<"="<<VK<<endl;
        cout<<"---------------------------"<<endl;
        cout<<"maka volume kubusnya adalah "<<VK<<endl;
    }{
cout<<"\n";
    }{ int jawab;
cout<<"\n";
cout<<"kembali ke menu? \n";
cout<<"1. YES \n";
cout<<"2. NO / EXIT \n";
cout<<"3. TRY AGAIN \n"<<endl<<endl;
cin>>jawab;
if (jawab==1)
goto menu;
else if(jawab==2)
goto exit;
else if(jawab==3)
goto kubus;
else
cout<<"KESALAHAN MENGINPUT"<<"\n"<<"PROGRAM OTOMATIS BERHENTI";
getch();
goto exit;
}


lingkaran:
    {
        float r,LL;
        cout<<"[LUAS LINGKARAN]"<<endl;
        cout<<"masukkan panjang jari-jari lingkarannya? ";
        cin>>r;
      
        cout<<"---------------------------"<<endl;
        cout<<"Rumus Luas Lingkaran = 3.14*r*r"<<endl;
        cout<<"---------------------------"<<endl;
        cout<<"diketahui : "<<endl;
        cout<<"phi = 3.14 "<<endl;
        cout<<"jari-jari (r) = "<<r<<endl;
        cout<<"---------------------------"<<endl;
        cout<<"JAWAB : "<<endl;
        cout<<"Luas = 3.14";
        cout<<"*"<<r;
        cout<<"*"<<r;
        cout<<"="<<LL<<endl;
        cout<<"---------------------------"<<endl;
        cout<<"Luas=3.14"<<r<<r<<LL<<endl;
        cout<<"\n maka luas lingkaran-nya adalah "<<LL<<endl;
    }{
cout<<"\n";
    }{ int jawab;
cout<<"\n";
cout<<"kembali ke menu? \n";
cout<<"1. YES \n";
cout<<"2. NO / EXIT \n";
cout<<"3. TRY AGAIN \n";
cin>>jawab;
if (jawab==1)
goto menu;
else if(jawab==2)
goto exit;
else if(jawab==3)
goto kubus;
else
cout<<"KESALAHAN MENGINPUT"<<"\n"<<"PROGRAM OTOMATIS BERHENTI";
getch();
goto exit;
}


selinder:
    {
        float r,t,VS,LL;
        cout<<"[VOLUME SILINDER]"<<endl;
        cout<<"masukkan panjang jari-jari silinder-nya? ";
        cin>>r;
        cout<<"masukkanb panjang tinggi silinder-nya? ";
        cin>>t;
      
        cout<<"---------------------------"<<endl;
        cout<<"Rumus Volume Silinder = 3.14*r*r*t"<<endl;
        cout<<"---------------------------"<<endl;
        cout<<"diketahui : "<<endl;
        cout<<"phi = 3.14 "<<endl;
        cout<<"jari-jari (r) = "<<r<<endl;
        cout<<"tinggi (t) = "<<t<<endl;
        cout<<"---------------------------"<<endl;
        cout<<"JAWAB : "<<endl;
        cout<<"V = 3.14";
        cout<<"*"<<r;
        cout<<"*"<<r;
        cout<<"*"<<t;
        cout<<"="<<VS<<endl;
        cout<<"=---------------------------"<<endl;
        cout<<"Luas=3.14"<<r<<r<<LL<<endl;
        cout<<"Volume=3.14"<<r<<r<<t<<VS<<endl;
        cout<<"\n maka volume silinder-nya adalah  "<<VS<<endl;
    }{
cout<<"\n";
    }{int jawab;
cout<<"\n";
cout<<"kembali ke menu? \n";
cout<<"1. YES \n";
cout<<"2. NO / EXIT \n";
cout<<"3. TRY AGAIN \n";
cin>>jawab;
if (jawab==1)
goto menu;
else if(jawab==2)
goto exit;
else if(jawab==3)
goto kubus;
else
cout<<"KESALAHAN MENGINPUT"<<"\n"<<"PROGRAM OTOMATIS BERHENTI";
getch();
goto exit;
}

exit:
{
cout<<"TERIMA KASIH TELAH MENGUNJUNGI PROGRAM WAHYU";
{return 0;
}
 }
}

2. LOOPING ANGKA


gambar 2 contoh program looping angka

SCRIPT :

#include <iostream.h>
void main()
{
cout<<"\t|    NAMA     : WAHYU NUGROHO INDRAWINATA         |"<<endl;
cout<<"\t|    NIM      : TI-111036                         |"<<endl;
cout<<"\t|    M.K      : Pemograman C++ (Tugas)            |"<<endl;
cout<<"\t|    Semester : III                               |"<<endl;
cout<<"\t|  Membuat program untuk menghitung rumus-rumus   |"<<endl<<endl;
     int i,a;
     cout<<"masukan nilai yang akan dilooping : ";
     cin>>a;
     for (i=0;i<=a;i+=2)
     {
         cout<<""<<i<<endl;
     }
}

Penulis : Wahyu Nugroho Indrawinata ~ Sebuah blog yang menyediakan berbagai macam informasi

Artikel TUGAS PERTEMUAN KE-3 ini dipublish oleh Wahyu Nugroho Indrawinata pada hari Minggu, 14 Oktober 2012. Semoga artikel ini dapat bermanfaat.Terimakasih atas kunjungan Anda silahkan tinggalkan komentar.sudah ada 0 komentar: di postingan TUGAS PERTEMUAN KE-3
 

0 komentar:

Posting Komentar