Penggunaan Library Di Project Metnum

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Project METNUM 2016

1. Import library ke project

2. Tambah / panggil library dengan cara berikut

3. Cara penggunaan library


ExpressionParser parser = new ExpressionParser();
// Buat calss variable
DoubleValue xval = new DoubleValue();
DoubleValue yval = new DoubleValue();
parser.Values.Add("x", xval);
parser.Values.Add("y", yval);
// tambah nilai varibale
xval.Value = 2; // Update value of "x"
yval.Value = 10; // Update value of "y"
double result = parser.Parse("x^3+5x^2-3");

4. Contoh aplikasi Kalkulator

using
using
using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
info.lundin.math;

namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox2.Text = "0";
textBox3.Text = "0";
textBox4.Text = "0";
}
private void button15_Click(object sender, EventArgs e)
{
try
{
// penggunaan library
ExpressionParser parser = new ExpressionParser(); // memanggil class
pada library
//tambahkan class variable
DoubleValue xval = new DoubleValue();
DoubleValue yval = new DoubleValue();

DoubleValue zval = new DoubleValue();


// Double nval = new DoubleValue(); // tambahakan dibawah jika
menambah varibale
// penambahan terserah tergantung pemakaian
// mencari variable
parser.Values.Add("x", xval);
parser.Values.Add("y", yval);
parser.Values.Add("z", zval);
// parser.Value.Add("n",nval); // tambahkan jika class varible telah
di tambahkan
// penambahan tergantung class varible yang di tambah
xval.Value = Convert.ToDouble(textBox2.Text); //
yval.Value = Convert.ToDouble(textBox3.Text); //
yval.Value = Convert.ToDouble(textBox4.Text); //
//
Convert.ToDouble(String);

isi nilai varible


isi nilai varible
isi nilai varible
nval.Value =

// cara medapatkan hasil


double result = parser.Parse(textBox1.Text);
textBox5.Text = result.ToString();
}
catch
{
MessageBox.Show("Periksa inputan anda !!!!");
}
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text += "7";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text += "8";
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text += "9";
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text += "4";
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text += "5";
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text += "6";
}
private void button7_Click(object sender, EventArgs e)
{

textBox1.Text += "1";
}
private void button11_Click(object sender, EventArgs e)
{
textBox1.Text += "2";
}
private void button12_Click(object sender, EventArgs e)
{
textBox1.Text += "3";
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text += ".";
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text += "0";
}
private void button16_Click(object sender, EventArgs e)
{
textBox1.Text += "/";
}
private void button14_Click(object sender, EventArgs e)
{
textBox1.Text += "*";
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text += "-";
}
private void button13_Click(object sender, EventArgs e)
{
textBox1.Text += "+";
}
private void button17_Click(object sender, EventArgs e)
{
int a =0;
a = textBox1.Text.Length;
textBox1.Text = textBox1.Text.Remove(a - 1, 1);
}
private void button18_Click(object sender, EventArgs e)
{
textBox1.ResetText();
textBox2.Text = "0";
textBox3.Text = "0";
textBox4.Text = "0";
textBox5.ResetText();
}
}
}

PERHATIKAN dan PAHAMI //KOMENT PADA


PROGRAM !!!!
SELAMAT MENGERJAKAN

You might also like