Pages

Senin, 16 Januari 2012

LUAS DAN KELILING [TUGAS]

  • LUAS DAN KELILING
  • #include 
    #include 
    #include 
    #include 
    
    void keluar();
    
    void luas_segitiga()
    {
    int a, t;
    float l,kel1,sisi_miring;
    clrscr();
    textcolor(5);
    gotoxy(20,5);cprintf("  LUAS SEGITIGA \r \n" );
    gotoxy(20,6);cprintf(" ----------------------- \r \n" );
    gotoxy(20,7);cprintf("  panjang alas     =  " ); cin >> a ;
    gotoxy(20,8);cprintf("  inputkan tinggi  =  ") ; cin >> t ;
    l = (a*t)/2;
    gotoxy(20,10);cprintf("  luas = "); cout << l << endl;
    sisi_miring =sqrt((a*a)+(t*t));
    kel1 = (a + t + sisi_miring) ;
    gotoxy(20,11);cprintf("  sisi miring = "); cout << sisi_miring  << endl;
    gotoxy(20,12);cprintf("  keliling    = "); cout << kel1  << endl;
    gotoxy(20,13);cprintf(" ----------------------- \r \n" );
    gotoxy(20,15);keluar();
    }
    
    void luas_persegi()
    {
    int s;
    float lu,kel2;
    
    clrscr();
    textcolor(6);
    gotoxy(20,5);cprintf ("   LUAS PERSEGI \r \n");
    gotoxy(20,6);cprintf ("  ------------------ \r \n" );
    gotoxy(20,7);cprintf ("   Panjang sisi = "); cin >> s ;
    lu = (s*s);
    gotoxy(20,9);cprintf ("   Luas     = " ); cout << lu  << endl;
    kel2 = (4*s) ;
    gotoxy(20,10);cprintf("   Keliling = ");cout << kel2  << endl;
    gotoxy(20,11);cprintf ("  ------------------ \r \n" );
    gotoxy(20,13);keluar();
    }
    
    void luas_ketupat()
    {
    int d;
    float luas,kel3,sisi,sd;
    clrscr();
    textcolor(9);
    gotoxy(20,5);cprintf ("    LUAS BELAH KETUPAT \r \n");
    gotoxy(20,6);cprintf (" ------------------------- \r \n");
    gotoxy(20,7);cprintf ("    Panjang diagonal = "); cin >> d ;
    luas = (d*d)/2;
    gotoxy(20,9);cprintf ("    Luas     = "); cout << luas  << endl;
    sd = d/2;
    sisi = sqrt((sd*sd)+(sd*sd));
    gotoxy(20,10);cprintf("    Sisi     = " ); cout<< sisi  << endl;
    kel3 = (4*sisi);
    gotoxy(20,11);cprintf("    Keliling = " );cout << kel3 << endl;
    gotoxy(20,12);cprintf (" ------------------------- \r \n");
    gotoxy(20,3);keluar();
    }
    
    void menu()
    {
    char pil;
    clrscr();
    textcolor(2);
    gotoxy(20,14);cprintf("  JUNED/11051103247 \r \n " );
    gotoxy(20,5);cprintf ("  LUAS DAN KELILING  \r \n " );
    gotoxy(20,6);cprintf (" -------------------  \r \n " );
    gotoxy(20,7);cprintf ("   1. segitiga         \r \n " );
    gotoxy(20,8);cprintf ("   2. persegi           \r \n " );
    gotoxy(20,9);cprintf ("   3. belah ketupat      \r \n " );
    cout<> pil;
    
    
    switch(pil)
    {
    case '1' : luas_segitiga();break;
    case '2' : luas_persegi();break;
    case '3' : luas_ketupat();
    default :
    gotoxy(20,3);cprintf(" input anda salah ....!!! ");getch();menu();
    }
    }
    
    void keluar()
    {
    char x ;
    textcolor(4);
    cprintf( " Kembali ke Menu ...? (Y/N) "); cin >> x;
    switch(x)
    {
    case 'Y' :
    case 'y' : menu();break;
    case 'N' :
    case 'n' :
    cout << " thankzzzz";break;
    default :
    {
    cprintf( " input salah ... \r \n");keluar();
    }
    }
    }
    
    void main ()
    {
    menu();
    }
    
    
    
    
    


Print Friendly and PDF

Artikel Terkait:

0 komentar:

Posting Komentar

Related Posts Plugin for WordPress, Blogger...