#include <math.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int a,b,t,x,keliling;
int s1,s2,s3;
float luas;
cout << " \t \t Rumus Segitiga " << endl;
cout << " Jenis Segitiga : " << endl;
cout << " ______________________ " << endl;
cout << " 1. Segitiga Siku-siku " << endl;
cout << " 2. Segitiga Sembarang " << endl;
cout << " Pilihan : "; cin >> x;
if ( x == 1 )
{
cout << " Segitiga Siku-siku " << endl;
cout << " Masukan Alas Segitiga : "; cin >> a; cout << endl;
cout << " Masukan Tinggi Segitiga : "; cin >> t; cout << endl;
cout << " Masukan Sisi Segitiga : "; cin >> b; cout << endl;
cout << " ___________________________ " << endl;
luas = (a*t)*1/2;
keliling = a+t+b;
cout << " Luas Segitiga : " << luas << endl;
cout << " Keliling Segitiga : " << keliling << endl;
}
if ( x == 2 )
{
cout << " Segitiga Sembarang " << endl;
cout << " Masukan Sisi 1 Segitiga : "; cin >> s1; cout << endl;
cout << " Masukan Sisi 2 Segitiga : "; cin >> s2; cout << endl;
cout << " Masukan Sisi 3 Segitiga : "; cin >> s3; cout << endl;
keliling = s1 + s2 + s3;
b = keliling * 1/2;
luas = sqrt ( b*(b-s1)*(b-s2)*(b-s3));
cout << " Luas Segitiga : " << luas << endl;
cout << " Keliling Segitiga : " << keliling << endl;
}
return 0;
}
Hasil ketika di jalankan . . . . .
Pilihan Menu |
Hasil untuk segitiga siku-siku |
Hasil dari segitiga sembarang |
0 komentar:
Posting Komentar