Tugas 5.2

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> using namespace std; //Nama : Asiyah Thufailah //Nim : 3420210005 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 Luas" << endl; cout << "Keliling Segitiga : " << perimeter << endl; } else { cout << "Mode tidak valid!" << endl; } cout << "==============================================" << endl; cout << "Asiyah Thufailah" << endl; cout << "asiyahtflh@gmail.com" << endl; return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines