Laporan Praktikum C++
NIM/ No. Reg.
|
:
|
49013055
|
Nama
|
:
|
Evi Septiyani
Suparno
|
email
|
:
|
evi_septiyani@ymail.com
|
Laporan
|
:
|
Modul IX
|
Coding
9_1
|
Source
Code dan deskripsi singkat
|
Modul9-1.h
#pragma once
namespace latihanmodul91 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Modul91
/// </summary>
public ref class Modul91 : public System::Windows::Forms::Form
{
public:
Modul91(void)
{
InitializeComponent();
//
//TODO: Add the constructor code
here
//
}
protected:
/// <summary>
/// Clean up any resources being
used.
/// </summary>
~Modul91()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^
button1;
private: System::Windows::Forms::Button^
button2;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer
support - do not modify
/// the contents of this method
with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(37, 218);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"Mulai";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Modul91::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(165, 218);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 1;
this->button2->Text = L"Selesai";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Modul91::button2_Click);
//
// Modul91
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 262);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Name = L"Modul91";
this->Text = L"Modul91";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show ("Hallo Semua, Saya EVI sedang sedang belajar C++") ;
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^
e) {
this->Close();
}
};
}
Modul9-1.cpp
#include "Modul9-1.h"
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^args){
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
latihanmodul91::Modul91 form;
Application::Run(%form);
}
Rubah beberapa setting
1. klik kanan pada project, pilih
properties, kemudian pilih linkerà system à sub sistem, dan pilih Windows (/SUBSYSTEM:WINDOWS)
2. klik advanced pada entry point ketikkan main
|
Jawaban pertanyaan
|
Modul9-1.h[Design]
Ketika diklik mulai akan muncul seperti dibawah ini
Kemudian ketika di klik ok, kembali ke form
sebelumnya
Setelah klik selesai maka form akan
tertutup.
|
Coding
9_2
|
Source
Code dan deskripsi singkat
|
Modul9-2.h
#pragma once
namespace Modul92 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Modul92
/// </summary>
public ref class Modul92 : public System::Windows::Forms::Form
{
public:
Modul92(void)
{
InitializeComponent();
//
//TODO: Add the constructor code
here
//
}
protected:
/// <summary>
/// Clean up any resources being
used.
/// </summary>
~Modul92()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^
textBox1;
protected:
private: System::Windows::Forms::TextBox^
textBox2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::TextBox^
textBox3;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Button^
button1;
private: System::Windows::Forms::ComboBox^
comboBox1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer
support - do not modify
/// the contents of this method
with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(12, 23);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(74, 20);
this->textBox1->TabIndex = 0;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(281, 23);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(83, 20);
this->textBox2->TabIndex = 1;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(245, 26);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(13, 13);
this->label1->TabIndex = 2;
this->label1->Text = L"=";
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(173, 23);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(61, 20);
this->textBox3->TabIndex = 3;
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(12, 64);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(55, 13);
this->label2->TabIndex = 4;
this->label2->Text = L"49013055";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(12, 84);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(111, 13);
this->label3->TabIndex = 5;
this->label3->Text = L"Evi Septiyani Suparno";
//
// button1
//
this->button1->Location = System::Drawing::Point(281, 64);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 6;
this->button1->Text = L"Hitung";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Modul92::button1_Click);
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^
>(4) {L"+", L"-", L"*", L"/"});
this->comboBox1->Location = System::Drawing::Point(101, 22);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(60, 21);
this->comboBox1->TabIndex = 7;
this->comboBox1->Text = L"+";
//
// Modul92
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(373, 121);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->button1);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Name = L"Modul92";
this->Text = L"Operator Aritmatika";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^
e) {
int nilaiA, nilaiB;
double hasil;
String^ operatornya;
nilaiA = int::Parse(textBox1->Text);
nilaiB = int::Parse(textBox3->Text);
operatornya = comboBox1->Text;
if (operatornya == "+")
hasil = Convert::ToDouble (nilaiA + nilaiB);
else if (operatornya == "-")
hasil = Convert::ToDouble (nilaiA - nilaiB);
else if (operatornya == "*")
hasil = Convert::ToDouble (nilaiA * nilaiB);
else if (operatornya == "/")
hasil = Convert::ToDouble(nilaiA)/Convert::ToDouble(nilaiB);
textBox2->Text = hasil.ToString ();
}
};
}
Modul9-2.cpp
#include "Modul9-2.h"
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^args){
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Modul92::Modul92 form;
Application::Run(%form);
}
Rubah beberapa setting
1. klik kanan pada project, pilih
properties, kemudian pilih linkerà system à sub sistem, dan pilih Windows (/SUBSYSTEM:WINDOWS)
2. klik advanced à pada entry point ketikkan main
|
Jawaban pertanyaan
|
Ketika di running akan muncul seperti dibawah ini
Cara kerja dari program tersebut yaitu
semacam kalkulator, contoh menginputkan angka pada textbox yang pertama dan
kedua dengan angka 2 maka apabila ditekan hitung maka akan muncul hasil
penjumlahan antara 2 + 2 = 4. Pada combobox pun bisa memilih operator yang
ingin dipilih, misal +,-,* atau /.
|
Coding
9_3
|
Source
Code dan deskripsi singkat
|
Modul9-3.h
#pragma once
namespace modul93 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Modul93
/// </summary>
public ref class Modul93 : public System::Windows::Forms::Form
{
public:
Modul93(void)
{
InitializeComponent();
//
//TODO: Add the constructor code
here
//
}
protected:
/// <summary>
/// Clean up any resources being
used.
/// </summary>
~Modul93()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^
textBox1;
protected:
private: System::Windows::Forms::TextBox^
textBox2;
private: System::Windows::Forms::TextBox^
textBox3;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::ComboBox^
comboBox1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Button^
button1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer
support - do not modify
/// the contents of this method
with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(13, 26);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(79, 20);
this->textBox1->TabIndex = 0;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(286, 26);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(95, 20);
this->textBox2->TabIndex = 1;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(178, 26);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(71, 20);
this->textBox3->TabIndex = 2;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(262, 29);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(13, 13);
this->label1->TabIndex = 3;
this->label1->Text = L"=";
this->label1->Click += gcnew System::EventHandler(this, &Modul93::label1_Click);
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^
>(4) {L"+", L"-", L"*", L"/"});
this->comboBox1->Location = System::Drawing::Point(104, 26);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(61, 21);
this->comboBox1->TabIndex = 4;
this->comboBox1->Text = L"+";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(22, 71);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(55, 13);
this->label2->TabIndex = 5;
this->label2->Text = L"49013055";
this->label2->Click += gcnew System::EventHandler(this, &Modul93::label2_Click);
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(22, 97);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(111, 13);
this->label3->TabIndex = 6;
this->label3->Text = L"Evi Septiyani Suparno";
//
// button1
//
this->button1->Location = System::Drawing::Point(310, 71);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 7;
this->button1->Text = L"Hitung";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Modul93::button1_Click);
//
// Modul93
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(404, 140);
this->Controls->Add(this->button1);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Name = L"Modul93";
this->Text = L"Operator Aritmatika";
this->Load += gcnew System::EventHandler(this, &Modul93::Modul93_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Modul93_Load(System::Object^ sender, System::EventArgs^
e) {//sebagai untuk meload form yang dibuat
}
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^
e) {//label untuk memberikan label "="
}
private: System::Void label2_Click(System::Object^ sender, System::EventArgs^
e) {//memberi label keterangan nim
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^
e) {//saat tombol hitung diklik maka akan menjalankan
operasi sebagai berikut
double nilaiA, nilaiB;//deklarasi
nilaiA dan nilaiB, untuk dapat menyimpan nilai yang memiliki angka dibelakang
koma
double hasil;//deklarasi hasil, untuk dapat
menyimpan nilai yang memiliki angka dibelakang koma
String^ operatornya;//deklarasi operator yang merupakan
string
nilaiA = double::Parse(textBox1->Text);//deklarasi textbox tempat menyimpan nilai, sebagai
nilaiA
nilaiB = double::Parse(textBox3->Text);//deklarasi textbox tempat menyimpan nilai, sebagai
nilaiB
operatornya = comboBox1->Text;//combobox sebagai untuk menyimpan
operator perhitungan
if (operatornya == "+")//jika
memilih tambah maka akan masuk penjumlahan
hasil = Convert::ToDouble (nilaiA + nilaiB);//menjalankan rumus penjumlahan dan
hasil akan disimpan pada variabel hasil
else if (operatornya == "-")//jika memilih tambah maka akan masuk pengurangan
hasil = Convert::ToDouble (nilaiA - nilaiB);//menjalankan rumus pengurangan dan
hasil akan disimpan pada variabel hasil
else if (operatornya == "*")//jika memilih tambah maka akan masuk perkalian
hasil = Convert::ToDouble (nilaiA * nilaiB);//menjalankan rumus perkalian dan
hasil akan disimpan pada variabel hasil
else if (operatornya == "/")//jika memilih tambah maka akan masuk pembagian
hasil = Convert::ToDouble(nilaiA)/Convert::ToDouble(nilaiB);//menjalankan rumus pembagian dan
hasil akan disimpan pada variabel hasil
textBox2->Text = hasil.ToString ();//hasil maka ditampilkan pada textbox2
}
};
}
Modul9-3.cpp
#include "Modul9-3.h"
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^args){
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
modul93::Modul93 form;
Application::Run(%form);
}
Rubah beberapa setting
1. klik kanan pada project, pilih
properties, kemudian pilih linkerà system à sub sistem, dan pilih Windows (/SUBSYSTEM:WINDOWS)
2. klik advanced à pada entry point ketikkan main
|
Jawaban pertanyaan
|
Ketika di running akan muncul seperti dibawah ini
Cara kerja dari program tersebut yaitu
semacam kalkulator, contoh menginputkan angka pada textbox yang pertama dan
kedua dengan angka 2 maka apabila ditekan hitung maka akan muncul hasil
penjumlahan antara 1.1 + 1.1 = 2.2. Pada combobox pun bisa memilih operator
yang ingin dipilih, misal +,-,* atau /. Perbedaannya disini yaitu dapat
melakukan perhitungan dalam bentuk pecahan.
|
Berikut video salah satu program pada modul 9
Part 1 :
Part 2 :
Tidak ada komentar:
Posting Komentar