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; }
Rabu, 25 Mei 2011
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 ;
}
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);
}
}
}
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;
}
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 :"<
}
Minggu, 03 April 2011
simulation program to purchase fuel
task group:
1. Mukti Fadlillah Ayudewi (10018052)
2. Franecia Kartika (10018078)
3. Peni Sukma Nur Pratiwi (10018034)
simulation buy fuel with specifications:
Input form:
money / how many liters that will be purchased
Type of fuel to be purchased
Indicators will continue (increasing 0.1liter) for the total price / number of liters of fuel purchased not exceed demand
Output states:
The number of liters purchased (if the input in the form of money)
Total money to be paid (if the input in the form liter)
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
class spbu (){
friend ostream& opreator<<(ostream&,spbu&); friend istream& operator>>(istream&,spbu&);
public :
void banyak();
void pilihan();
void hitung_liter();
void hitung_harga();
private :
int harga;
int Biaya;
int a,b ;
float hasil ;
float premium ;
float solar ;
float pertamax ;
};
void banyak::liter(){
cout<<"Masukkan berapa liter yang dibutuhkan : "; cin>>x;
}
void banyak::pilihan(){
cout<<"pilih 1 untuk premium\n"<>y;
}
void banyak::hitung_liter(){
float i = 0.0;
while(i <= x){
i = i + 0.1;
cout< }
}
void banyak::hitung_harga(){
float hasil = 0.0;
float premium = 4500;
float solar = 6000;
float pertamax = 8000;
if(y == 1)
hasil = x * premium;
else if(y == 2)
hasil = x * solar;
else if(y == 3)
hasil = x * pertamax;
cout<<"harga : "<
}
void main(){
spbu :
banyak.banyak();
banyak.harga();
banyak.hitung_liter();
banyak.hitung_harga();
system("PAUSE");
return EXIT_SUCCESS;
}
1. Mukti Fadlillah Ayudewi (10018052)
2. Franecia Kartika (10018078)
3. Peni Sukma Nur Pratiwi (10018034)
simulation buy fuel with specifications:
Input form:
money / how many liters that will be purchased
Type of fuel to be purchased
Indicators will continue (increasing 0.1liter) for the total price / number of liters of fuel purchased not exceed demand
Output states:
The number of liters purchased (if the input in the form of money)
Total money to be paid (if the input in the form liter)
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
class spbu (){
friend ostream& opreator<<(ostream&,spbu&); friend istream& operator>>(istream&,spbu&);
public :
void banyak();
void pilihan();
void hitung_liter();
void hitung_harga();
private :
int harga;
int Biaya;
int a,b ;
float hasil ;
float premium ;
float solar ;
float pertamax ;
};
void banyak::liter(){
cout<<"Masukkan berapa liter yang dibutuhkan : "; cin>>x;
}
void banyak::pilihan(){
cout<<"pilih 1 untuk premium\n"<
}
void banyak::hitung_liter(){
float i = 0.0;
while(i <= x){
i = i + 0.1;
cout< }
}
void banyak::hitung_harga(){
float hasil = 0.0;
float premium = 4500;
float solar = 6000;
float pertamax = 8000;
if(y == 1)
hasil = x * premium;
else if(y == 2)
hasil = x * solar;
else if(y == 3)
hasil = x * pertamax;
cout<<"harga : "<
void main(){
spbu :
banyak.banyak();
banyak.harga();
banyak.hitung_liter();
banyak.hitung_harga();
system("PAUSE");
return EXIT_SUCCESS;
}
program java menghitung nilai faktorial
Award as the value of factorial is the result of the multiplication of positive integers less than or equal to the value N. Writing is usually a factorial: n!
berikut programnya :
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);
}
}
}
berikut programnya :
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);
}
}
}
Minggu, 27 Maret 2011
program memindahkan nilai a ke b dan b ke a (menggunakan jeliot)
public class MyClass {
public static void main() {
// Your algorithm goes here.
}
}
/* Program Pertukaran nilai A dan B */
class ProgramPertukaran
{
public static void main (String [] X)
{
/*Deklarasi Variabel*/
String nilaiA="dua"; // isi nilai A sebelum pertukaran
String nilaiB="delapan"; // isi nilai B sebelum pertukaran
String t;// tempat Sementara
/*Algoritma*/
/*Proses Pertukaran*/
t=nilaiA;/*simpan nilai A di tempat penampungan sementara*/
nilaiA=nilaiB;/*sekarang A dapat diisi dengan nilai B*/
nilaiB= t;/*isi B dengan nilai A yang semula ada di temp*/
/*tampilkan nilai setelah pertukaran*/
System.out.println("::Setelah Pertukaran::");
System.out.println("nilai A Sekarang ="+nilaiA);
System.out.println("nilai B sekarang ="+nilaiB);
}
}
public static void main() {
// Your algorithm goes here.
}
}
/* Program Pertukaran nilai A dan B */
class ProgramPertukaran
{
public static void main (String [] X)
{
/*Deklarasi Variabel*/
String nilaiA="dua"; // isi nilai A sebelum pertukaran
String nilaiB="delapan"; // isi nilai B sebelum pertukaran
String t;// tempat Sementara
/*Algoritma*/
/*Proses Pertukaran*/
t=nilaiA;/*simpan nilai A di tempat penampungan sementara*/
nilaiA=nilaiB;/*sekarang A dapat diisi dengan nilai B*/
nilaiB= t;/*isi B dengan nilai A yang semula ada di temp*/
/*tampilkan nilai setelah pertukaran*/
System.out.println("::Setelah Pertukaran::");
System.out.println("nilai A Sekarang ="+nilaiA);
System.out.println("nilai B sekarang ="+nilaiB);
}
}
Langganan:
Postingan (Atom)