tugas 5.2

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <cmath> using namespace std; //nama: yoga dwi kurniawan //nim : 3420230019 int main() { int mode; float base, height, side, perimeter, area; cout << "==============================================" << endl; cout << " Program Menghitung Segitiga Sama Kaki" << endl; cout << "==============================================" << endl; cout << "Masukkan Mode\n [1:Luas, 2:Keliling]\n "; cin >> mode; cout << "Masukkan Alas Segitiga :\n "; cin >> base; cout << "Masukkan Tinggi Segitiga:\n "; cin >> height; cout << "==============================================" << endl; // Calculate the side length using the Pythagorean theorem if (mode == 1) { // Calculate area area = (base * height) / 2; cout << "Nilai Alas Adalah : " << base << endl; cout << "Nilai Tinggi Adalah : " << height << endl; cout << "Mode yang dipilih : Menghitung Luas" << endl; cout << "Luas Segitiga : " << area << endl; } else if (mode == 2) { // Calculate perimeter perimeter = base * height; cout << "Nilai Alas Adalah : " << base << endl; cout << "Nilai Tinggi Adalah : " << height << endl; cout << "Mode yang dipilih : Menghitung Keliling" << endl; cout << "Keliling Segitiga : " << perimeter << endl; } else { cout << "Mode tidak valid!" << endl; } cout << "==============================================" << endl; cout << "Yoga Dwi Kurniawan" << endl; cout << "Yoga2211dwi@gmail.com" << endl; return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines