Pages

Senin, 18 Mei 2015

TUGAS PEMOGRAMAN MATERI OBJECT ORIENTED PROGRAM(OPP)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form //class 
    {
        public Form1() //object
        {
            InitializeComponent();
         
        }
            int x = 0;//Field(variable x mewakilkan kecepatan)
            int a= 0;//Field (variable a mewakilkan volume bensin)
            
         
        private void button1_Click(object sender, EventArgs e)
        {

            x++; //methode(kecepatan ditambah)
            textBox1.Text = x.ToString();//kecepatan yg di simbolkan variable x yang sudah di tambah di tampilkan di textBox 1
            progressBar1.Value = x;//kecepatan yg di simbolkan variable x yg sudah di tambahkan di tampilkan di progressBar1
           

        }

        private void button2_Click(object sender, EventArgs e)
        {
         
         

            x--;//methode(kecepatan dikurangi)
            if(x<=0)//(jika kecepatan dikurangi sampai x lebih kecil dari sama dengan nol kecepatan bernilai nol)
               x=0;
            textBox1.Text = x.ToString();//kecepatan yg di simbolkan variable x yg sudah di dikurangi di tampilkan di textBox1

            progressBar1.Value = x;//kecepatan yg di simbolkan variable x yg sudah di kurangi di tampilkan di progressBar1
         
       
        }

        private void button3_Click(object sender, EventArgs e)
        {


            a++;//methode(volume bensin di tambah)
            textBox2.Text = a.ToString();//volume bensin  yg di simbolkan variable a yg sudah di tambahkan di tampilkan di textBox2
         
            progressBar2.Value = a;//volume bensin yg di simbolkan variable a yg sudah di tambahkan di tampilkan di progressBar2
         

        }

        private void button4_Click(object sender, EventArgs e)
        {
            a--;//methode(volume bensin di kurangi)
            if (a <= 0)//(jika volume bensin dikurangi sampai a lebih kecil dari sama dengan nol  volume bensin bernilai nol)
                a = 0;
            textBox2.Text = a.ToString();//volume bensin yg di simbolkan variable a yg sudah di kurangi di tampilkan di textBox2
            progressBar2.Value = a;//volume bensin yg di simbolkan variable a yg sudah di kurangi di tampilkan di progressBar2
        }

     

    }
}

GAMBAR :


Minggu, 29 Maret 2015

PROGRAM MATRIKS PENJUMLAHAN C++

#include<stdio.h>
#include<conio.h>


void main()

{
int i,j,n,k,x,y,a[100][100],b[100][100],c[100][100];

printf("masukkan baris :");
scanf("%d",&x);

printf("masukkan kolom :");
scanf("%d",&y);

for(i=1;i<=x;++i)
{
for(j=1;j<=y;++j)
{
printf("Baris %d kolom %d :",i,j);
scanf("%d",&a[i][j]);
}
}

printf("Matriks A =>");
printf("\n");
for(i=1;i<=x;++i)
{
for(j=1;j<=y;++j)

printf("%d ",a[i][j]);
printf("\n");

}
for(i=1;i<=x;++i)
{
for(j=1;j<=y;++j)
{
printf("Baris %d kolom %d :",i,j);
scanf("%d",&b[i][j]);
}
}
printf("Matriks B =>");
printf("\n");
for(i=1;i<=x;++i)
{
for(j=1;j<=y;++j)

printf("%d ",b[i][j]);
printf("\n");

}
printf("Matriks c hasil pertambahan adalah: =>");
printf("\n");

for(i=1;i<=x;++i)
for(j=1;j<=y;++j)
c[i][j]=a[i][j]+b[i][j];

for(i=1;i<=x;++i)
{
for(j=1;j<=y;++j)

printf("%d ",c[i][j]);
printf("\n");

}








getch();





}

PROGRAM MENCARI NILAI MAX DARI 3 INPUT BILANGAN

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
       
       
            double bil1;
            double bil2;
            double bil3;
            double max;
            bil1 = Convert.ToDouble(textBox1.Text);
            bil2 = Convert.ToDouble(textBox2.Text);
            bil3 = Convert.ToDouble(textBox3.Text);


            if (bil1 > bil2)
            {
                if (bil1 > bil3)
                    max = bil1;
                else
                    max = bil3;
                textBox4.Text = max.ToString();
            }
            else if (bil1 > bil3)
            {
                if (bil1 > bil2)
                    max = bil1;
                else
                    max = bil2;
                textBox4.Text = max.ToString();
            }
            else if (bil2 > bil1)
            {
                if (bil2 > bil3)
                    max = bil2;
                else
                    max = bil3;
                textBox4.Text = max.ToString();
            }
           
        }
    }
}


PROGRAM MENCARI KONVERSI SUHU DARI CELCIUS KE SUHU LAIN DENGAN C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double celcius;
            double fahrenheit;
            double reamur;
            double kelvin;
       
         
            if (radioButton1.Checked == true)
            {
                celcius = Convert.ToDouble(textBox1.Text);
                reamur = celcius * 4 / 5;
                textBox2.Text = reamur.ToString();
            }
            else
            {

                if (radioButton2.Checked == true)
                {
                    celcius = Convert.ToDouble(textBox1.Text);
                    kelvin = celcius + 273;
                    textBox2.Text = kelvin.ToString();

                }
                else
                {
                    celcius = Convert.ToDouble(textBox1.Text);
                    fahrenheit = (celcius + 32) * 9 / 5;
                    textBox2.Text = fahrenheit.ToString();
               
                }

            }
           

        }
    }
}