Rabu, 25 Mei 2011

arithmetic series (deret aritmatika)

Arithmetic series in the field of mathematics is the sequence number in which the next number of additions to the previous number by a number of specific differences. Examples are 3,5,7,9,11,13, ..... Arithmetic series can be expressed with the following formula:

a, a + b, a + 2b, a + 3b, ...

In this case the n-th quarter:

\ a_n = a + (n - 1) b,

The total of all quarters:

S_n = \ frac {n} {2} (a + a_n) = \ frac {n} {2} [2a + (n-1) b].

For example, the sum total of a quarter to quarter of an = 3 + (n-1) (5) up to a quarter-50 is

S_ {50} = \ frac {50} {2} [2 (3) + (49) (5)] = 6.275.

Algorithm deret aritmatika :
Deklarasi:
float a, b, n, un, sn: Integer
int x;

Deskripsi:
For ← (x = a, x <= un, x = x + b) a 1.0 ←, b ← 2.0; ← printf ("+% i ", x); EndFor write (Deret aritmatika)
following his program c + + :


#include
#include

using namespace std;

int main(int argc, char *argv[])
{
//deklarasi data
float a,b,n,un,sn;
int x;
//badan program
printf("Program Penghitung Deret Aritmatika");
printf("\nMasukkan:");
printf("\nSuku ke n = ",n);
scanf("%f",&n);

a = 1.0;
b = 2.0;

un = a + (n-1)*b;
sn = (0.5*n)*(a+un);

printf("\nMaka Nilai dari Un = %f\n",un);
printf("\nNilai Sn = %f\n",sn);

printf("\nSelanjutnya\n");
printf("\nUn = %f\n",un);
printf("\nDeret aritmatika untuk %f adalah :\n\n",un);

for(x=a;x<=un;x=x+b) { printf("+%i ",x); } system("PAUSE"); return EXIT_SUCCESS; }

JAVA program Calculating Area and Volume of Balls

The ball is hand built curved space bounded by a curved area. The ball can be formed from the wake half-circle that rotated as far as 360 ° in diameter.

Algorithm to find the ball wide:

Input the radius = r
Input pi = 3.14
Calculate the area of ​​L = pi * r * r
Print Size L.


Volume ball search algorithm


Input the radius = r
Input pi = 3.14
Calculate the volume V = pi * r * r * r
Print Volume V.

The following program :

import jeliot.io.*;

public class GlobalMembers
{
public static void main()
{
libo x = new libo();
x.masukan();
System.out.print(" hasilnya adalah \n");
x.ngitung();
}
}

public class libo
{
public final void masukan()
{
System.out.print("masukkan nilai r :");
r = Input.readInt();
}
public final void ngitung()
{
pi +=3.14;
volume =(4/3)*pi*r*r*r;
luas =pi*r*r;
System.out.print("luas =");
System.out.print(luas);
System.out.print("\n");
System.out.print("volume =");
System.out.print(volume);
System.out.print("\n");
}
private int r;
private float pi ;
private float volume ;
private float luas ;

}

Menghitung Nilai Faktorial menggunakan Program JAVA

a glimpse of the factorial :

Here we let (n) as the number who would we look for value faktorialnya.
In mathematics the factorial of a bialngan formulated by:

n! = n * (n-1) ... ... * 1

or

n! = 1 * (n 1) ... ..* n


ALGORITHM calculate the factorial :

1.Tentukan fariabel i, n, factorial
2.faktorial = 1;
3.scanf (n)
4.for (i = 1; i <= n; i) {factorial = factorial * i;} 5.printf (factorial); 6.End.
The following java program :

import jeliot.io.*;


public class faktorial
{
public static void main (String[ ] args)
{
long limit = 20; // menghitung faktorial integer daeri 1 – 20
long faktorial = 1; // pendefinisian variabel faktorial

for (int i = 0; i <= limit; i++)
{
faktorial = 1;

for (int faktor = 2; faktor <= i; faktor ++)
faktorial *= faktor;
System.out.println (i + "!" + " adalah " + faktorial);
}
}
}

Program Menghitung Matrik Berordo 2x2

Sekilas tentang Matrik :

Notasi suatu matrik berukuran n x m ditulis dengan huruf besar dan dicetak tebal,
misalnya An×m. Huruf n menyatakan jumlah baris, dan huruf m jumlah kolom. Matrik
terdiri dari elemen-elemen matrik yang dinyatakan dengan huruf kecil diikuti
angka-angka indeks, misalnya aij , dimana i menunjukan posisi baris ke-i dan j
menentukan posisi kolom ke-j.


Berikut Program C++ untuk menghitung determinan matrik berordo 2x2 :

Algoritma :
1. Input a
2. Input b
3. Input c
4. Input d
5. Determinan = a*d-b*c

Program :

#include

int main()
{
int a,b,c,d,det;
cout<<"masukkan a :"; cin>>a;
cout<<"masukkan b :"; cin>>b;
cout<<"masukkan c :"; cin>>b;
cout<<"masukkan d :"; cin>>d;
det= a*d-b*c;
cout<<"determinan :"< return 0;
}