Algoritma14.1

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> using namespace std; void garis() { cout<<"=============================================\n"; } struct { string nama; string email; } author; class bujursangkar { private: //Variable Private int panjang, lebar; public: //Prototipe Function void set_nilai(int x,int y); int luas(); }; void bujursangkar::set_nilai(int x, int y) { panjang = x; lebar = y; } int bujursangkar::luas() { return panjang * lebar; } void cetak_author(string nama, string email) { garis(); cout<<"Nama : "<<nama<<endl; cout<<"Email : "<<email<<endl; } int main() { //Set Nilai Struct author.nama = "Irsyad Purbha"; author.email = "irsyadpurbha.fst@uia.ac.id"; int p1, p2, l1, l2; //Create Object bujursangkar bs1; bujursangkar bs2; cout<<"Bujur Sangkar 1"<<endl; garis(); cout<<"Panjang : <input>";cin>>p1;cout<<endl; cout<<"Lebar : <input>";cin>>l1;cout<<endl; bs1.set_nilai(p1,l1); cout<<"Luas : "<<bs1.luas(); cout<<endl<<endl; cout<<"Bujur Sangkar 2"<<endl; garis(); cout<<"Panjang : <input>";cin>>p2;cout<<endl; cout<<"Lebar : <input>";cin>>l2;cout<<endl; bs2.set_nilai(p2,l2); cout<<"Luas : "<<bs2.luas(); cout<<endl<<endl; cetak_author(author.nama,author.email); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines