#include <iostream>
//Nama : Fara Novri Hasbel Wijaya
//NIM : 3420230017
using namespace std;
int main() {
int mode, alas, tinggi;
cout << "=============================================" << endl;
cout << "Program Menghitung Segitiga Sama Kaki\n";
cout << "=============================================" << endl;
cout << "Masukan Mode\n";
cout << "[1:Luas, 2:Keliling]\n";
cout << "Masukan Mode: ";
cin >> mode;
cout << "\nMasukan Alas Segitiga: ";
cin >> alas;
cout << "\nMasukan Tinggi Segitiga: ";
cin >> tinggi;
cout << "\n=============================================" << endl;
// Validasi input
if (alas <= 0 || tinggi <= 0) {
cout << "Alas dan Tinggi harus lebih besar dari 0." << endl;
return 1;
}
cout << "Nilai Alas Adalah: " << alas << endl;
cout << "Nilai Tinggi Adalah: " << tinggi << endl;
if (mode == 1) {
// Menghitung luas
float luas = 0.5 * alas * tinggi;
cout << "Mode yang dipilih: Menghitung Luas" << endl;
printf("Luas Segitiga: %.2f\n", luas);
} else if (mode == 2) {
// Menghitung keliling
float sisiMiring = (alas / 2) + (tinggi * 2) / 2;
float keliling = alas * tinggi;
cout << "Mode yang dipilih: Menghitung Keliling" << endl;
printf("Keliling Segitiga: %.2f\n", keliling);
cout << "=============================================" << endl;
} else {
cout << "Mode tidak valid!" << endl;
}
cout << "Fara Novri\nfaranovri@gmail.com" << endl;
cout << "=============================================" << endl;
return 0;
}