Latihan Modul 9
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
double nilaia,nilaib; //deklarasi variabel double nilaia dan nilai b
double hasil; //deklarasi variabel double hasil
String^ operatornya; //deklarasi String^ operatornya
nilaia=double::Parse(textBox1->Text); //nilaia diletakkan di textbox1
nilaib=double::Parse(textBox2->Text); //nilaib diletakkan di textbox2
operatornya=comboBox1->Text; //operatornya diletakkan di combobox1
if(operatornya=="+") //jika operatornya +
hasil=Convert::ToDouble(nilaia+nilaib); //nilaia + nilaib diconvert ke double disimpan di variabel hasil
else if(operatornya=="-") //jika operatornya -
hasil=Convert::ToDouble(nilaia-nilaib); //nilaia - nilaib diconvert ke double disimpan di variabel hasil
else if(operatornya=="*") //jika operatornya *
hasil=Convert::ToDouble(nilaia*nilaib); //nilaia x nilaib diconvert ke double disimpan di variabel hasil
else if(operatornya=="/") //jika operatornya /
hasil=Convert::ToDouble(nilaia)/Convert::ToDouble(nilaib); //nilaia : nilaib diconvert ke double disimpan di variabel hasil
textBox3->Text=hasil.ToString(); //textbox3 menampilkan nilai dari variabel hasil
}
Wednesday, November 20, 2013
Modul 9: Pembuatan Program Aplikasi Berbasis Windows
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment