Pages

Saturday, March 25, 2017

Script C++ Perulangan

dipostingan kali ini saya akan memberikan Script C++ pemprograman dasar tentang Perulangan,Semoga bermanfaat untuk kalian yang baru belajar Pemprograman dan semoga dapat di pahami oleh kalian, jika kalian membutuhkan Software kalian bisa download di sini





Script Program :



#include "iostream.h"
#include "conio.h"
#include "windows.h"
main(){
int pilih;
char nama [30];
float Li,r,Lp,p,l,Ls,a,t;
const float phi=3.14;
cout<<"=========================\n";
cout<<" PROGRAM MENU HITUNG\n";
cout<<"=========================\n";
cout<<"1.Hitung Luas Lingkaran\n";
cout<<"2.Hitung Luas Persegi\n";
cout<<"3.Hitung Luas Segitiga\n";
cout<<"4.Keluar\n";
cout<<"=========================\n\n";
cout<<"Nama Anda :";
cin>>nama;
cout<<"\nSelamat Datang ["<<nama;
cout<<"] di Aplikasi Menghitung\n\n\n";

while(pilih>=0){
cout<<"Pilihan Anda (1/2/3/4) :";
cin>>pilih;
switch(pilih){
case 1:
cout<<"=================================\n";
cout<<" Menghitung Luas Lingkaran\n";
   cout<<"=================================\n";
cout<<"Masukan jari - jari :";
   cin>>r;
Li=phi*r*r;
cout<<"Luas Lingkaran adalah :"<<Li<<"\n";
   cout<<"---------------------------------\n\n\n";
break;
case 2:
cout<<"================================\n";
cout<<" Menghitung Luas Persegi\n";
      cout<<"================================\n";
      cout<<"Masukan Panjang Persegi :";
      cin>>p;
      cout<<"Masukan Lebar Persegi :";
      cin>>l;
      Lp=p*l;
      cout<<"Hasil Luas Persegi Adalah :"<<Lp<<"\n";
      cout<<"--------------------------------\n\n\n";
      break;
      case 3:
         cout<<"==================================\n";
         cout<<" Menghitung Luas Segitiga\n";
         cout<<"==================================\n";
         cout<<"Masukan Alas Segitiga :";
         cin>>a;
         cout<<"masukan Tinggi Segitiga :";
         cin>>t;
         Ls=0.5*a*t;
         cout<<"Hasil Luas Segitiga Adalah :"<<Ls<<"\n";
         cout<<"----------------------------------\n\n\n";
         break;
          case 4:
            cout<<"================================\n";
            cout<<">>  TRIMAKASIH << \n";
            cout<<"================================\n";
            break;
          default:
            cout<<"KODE YANG ANDA MASUKAN SALAH !!!!!!\n";
            }
            }
getch();
}




No comments:

Post a Comment