Friday, 22 April 2011

Analysis program:

Already know it primes?? A prime number (or a prime) is a natural number that has exactly two distinct natural number divisors: 1 and itself. For example, we input the number 3 it will be in the process with thisprogram that the results are excellent.

Algorithm:
1. Suppose this number is X.
2. number is even or odd.
3. If the numbers are completed (except 2) means not a prime number.
4. Numbers were only divisible by 1 and the number itself or not?
5. If not, then not a prime number.
6. If so, then the prime numbers.

Program :

[sourcecode language="css"]
#include <iostream.h>

class prima
{
public:
prima();
input();
proses();
private:
int bil, batas, x, i;
};

prima::prima()
{ cout<<"Menentukan bilangan prima atau bukan"<<endl<<endl;}
prima::input()
{ cout << "Masukkan bilangan : ";
cin >> x;
cout<<endl;}
prima::proses(){
batas = 0;
for ( i=1; i<=bil; i++)
{
if (bil%i==0 && x !=0)
batas++; }

if (batas==2){
cout << "Termasuk bilangan prima \n"; }
else {
cout << "Bukan bilangan prima \n";}
}

int main()
{
prima bilangan;
bilangan.input();
bilangan.proses();

}
[/sourcecode]

Posted on 20:52 by yusufruli

No comments

Sebelumnya bisa mendownloadnya , klik DISINI

Algritmanya :

1.Inputan : Pilih operasi yang akan dipakai, masukan bilangan yang akan dihitung.

2.Hitung inputan dengan operasi yang dipilih.
Proses masing-masing operasi:
Akar Kuadrat = √a
Log = log(a)
Perpangkatan(^) = a^n
Sin = sin(a)
Cos = cos(a)
Tan = tan(a)

3.Output : Tampilan hasil dari proses perhitungan tersebut.

Program :
Ini adalah tugas saya membuat kalkulator. Disini saya menggunakan dev c++. Tetapi bisa anda coba dengan apapun, tinggal menyesuaikan perintahnya. Langsung saja sedikit saya beri penjelasan...
Buka dev C++ dan buat project baru.
Buat juga headernya lalu simpan dengan nama _yusuf.h
Kemudian ketik programnya di bawah ini.
[sourcecode language="css"]
#include <cstdlib>
#include <iostream.h>
#include <math.h>
using namespace std;

class kalkulator {

public:
void menu();
void prosesnya();

private:
int yusuf;
float a,b,hasil;
};

void kalkulator::menu(){
cout<<" ___________________________________________________ \n";
cout<<" ||||||||||||||||||||||||||||||||||||||||||||||||||| \n";
cout<<" =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.= \n";
cout<<" =.=.=.=.=.= KALKULATOR SEDERHANA SAYA =.=.=.=.=.=.= \n";
cout<<" =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.= \n";
cout<<" =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.= \n";
cout<<" =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.= \n";
cout<<" =.=.=.=.=. Y U S U F =.=.=.= \n";
cout<<" =.=.=.=.=. R U L I A N T O K O =.=.=.= \n";
cout<<" =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.= \n";
cout<<" =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.= \n";
cout<<" =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.= \n";
cout<<" =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.= \n";
cout<<" =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.= \n";
cout<<" ||||||||||||||||||||||||||||||||||||||||||||||||||| \n";
cout<<" ___________________________________________________ \n\n";
cout<<" Anda Mau Menghitung Tentang Apa\n";
cout<<" 1. Akar Kuadrat \n";
cout<<" 2. log(a) \n";
cout<<" 3. Perpangkatan(^)\n";
cout<<" 4. Sin(a) \n";
cout<<" 5. Cos(a) \n";
cout<<" 6. Tan(a) \n";

}

void kalkulator::prosesnya(){
cout<<" Masukan pilihan Anda : ";
cin>>yusuf;
switch(yusuf){
case 1:
cout<<"\n Akar Kuadrat\n";
cout<<" masukkan angka : ";cin>>a;
hasil=sqrt(a);
cout<<" Hasil Akar Kuadrat "<<a<<" = "<<hasil<<endl<<endl;
break;

case 2:
cout<<"\n Log(a)\n";
cout<<" masukkan angka : "; cin>>a;
hasil=log(a);
cout<<" Hasil Log ("<<a<<")"<<" = "<<hasil<<endl<<endl;
break;

case 3:
cout<<"\n Masukkan bilangan yang akan dipangkatkan :";cin>>a;
cout<<" Masukkan pangkat dari "<<a<<" : ";cin>>b;
hasil=pow(a,b);
cout<<" Hasil "<<a<<" pangkat "<<b<<" = "<<hasil<<endl<<endl;
break;

case 4:
cout<<"\n Sin(a)\n";
cout<<" masukkan angka : ";cin>>a;
hasil=sin(a);
cout<<" Hasil Sin "<<a<<" = "<<hasil<<endl<<endl;
break;

case 5:
cout<<"\n Cos(a)\n";
cout<<" masukkan angka :";cin>>a;
hasil=cos(a);
cout<<" Hasil Cos "<<a<<" = "<<hasil<<endl<<endl;
break;

case 6:
cout<<"\n Tan(a)\n";
cout<<" masukkan angka : ";cin>>a;
hasil=tan(a);
cout<<" Hasil Tan "<<a<<" = "<<hasil<<endl<<endl;
break;

default :
cout<<" Yang anda masukkan salah !!!\n";
cout<<" Tidak ada pilihan, Pilihan terdiri 1-6\n\n";
prosesnya();
break;

}
}

[/sourcecode]

Langkah terakhir membuat file utama yang berisi fungsi main. Buat Souce File lalu ketik program di bawah ini.

[sourcecode language="css"]
#include <iostream.h>
#include <math.h>
#include "_yusuf.h"

int main()
{
kalkulator sederhana;
char yn;
do
{
sederhana.menu();
sederhana.prosesnya();
cout<<" Ingin menghitung lagi ??\n";
cout<<" Tekan --Y-- untuk lanjut atau --N-- untuk keluar\n ";
cin>>yn;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
}
while(yn=='y' || yn=='Y');

system("PAUSE");
return 0;
}

[/sourcecode]

Posted on 20:28 by yusufruli

No comments

Analysis program:
This is a program iteraktif to find the sum of the input sequence (n). Please try running.

Program :
[sourcecode language="css"]
#include <iostream.h>
#include<conio.h>

class hitung
{
public:
void input();
int proses();
private:
int n;
float rumus,jumlah,total;
};

void hitung::input(){
cin>>n;
cout<<endl;}

int hitung::proses(){
jumlah=0;
total=0;
rumus=-1;
for(int j=1; j<=n; j++){
rumus=(rumus*(-1));
total=rumus/j;
jumlah+=total;
if(j==1)
cout<<"("<<total<<")";
if(j>1)
cout<<"+("<<total<<")";
}

cout<<endl<<endl<<"hasil penjumlahan deret = "<<jumlah;
return jumlah;
}

int main()
{
cout<<"menghitung jumlah dari rumus 1-(1/2)+(1/3)-(1/4)+...+(1/n)"<<endl<<endl;
cout<<"nilai n : ";
hitung deret;
deret.input();
deret.proses();

getch();
return 0;
}


[/sourcecode]

Jeliotnya :
[sourcecode language="css"]
import jeliot.io.*;

public class MyClass {

public static double iteratif(double x){
double jumlah=0.0;
for(int i=1; i<=x; i++){
if(i % 2 == 0) jumlah=jumlah-1.0/i;
else jumlah=jumlah+1.0/i;
}
return jumlah;
}

public static double rekursif(double x){
double jumlah=0.0;
if(x==1) return 1;
else if(x % 2 == 0) jumlah= -1.0/x + rekursif(x-1);
else jumlah= 1.0/x + rekursif(x-1);
return jumlah;
}

public static void main() {
double x;

MyClass a = new MyClass();
System.out.print("Masukkan batas bilangan : ");
x=Input.readDouble();
System.out.println("Hasil iteratif : " + iteratif(x));
System.out.print("Hasil rekursif : " + rekursif(x));

}
}

[/sourcecode]

Posted on 20:10 by yusufruli

No comments

Monday, 18 April 2011

Analysis program :
The program is to convert a numeric value to lower case by using the function if else. Using the integer data type as input the numerical value and char data type with the output value.

[sourcecode language="css"]

#include <iostream.h>

class nilai {
public :
void masukan();
void proses();
private:
int nilai;
char hasil;};
void nilai::masukan() {
cout<<"Masukkan Angka : ";cin>>nilai;}
void nilai::proses() {
if ((nilai>0) && (nilai <=20))
cout<<" hurufnya : E"<<endl;
else if ((nilai>20) && (nilai <=40))
cout<<" hurufnya : D"<<endl;
else if ((nilai>40) && (nilai <=60))
cout<<" hurufnya : C"<<endl;
else if ((nilai>60) && (nilai <=80))
cout<<" hurufnya : B"<<endl;
else if ((nilai>80) && (nilai <=100))
cout<<" hurufnya : A"<<endl;
else
cout<<"Angka tidak ada inputannya harus 0-100 !!!"<<endl;}
int main(){
nilai x;
x.masukan();
x.proses();
getch();
}

[/sourcecode]

Posted on 05:12 by yusufruli

No comments

Analysis Program :
This program to find out the name of the day if we input the number. The process uses a switch case. We can input the numbers 1 through 7. If more than 7 or 0, then the program can not determine because already know right? Yes. Because there are only 7 days a week

Program :
[sourcecode language="css"]

#include <iostream.h>

class HARI {
public:
hari();
private:
int dino;
};
HARI::hari() {
cout<<"Masukan angka = ";
cin>>dino;
switch (dino) {
case 1:
cout<<"Hari ke : "<<dino<<" = Senin";break;
case 2:
cout<<"Hari ke : "<<dino<<" = Selasa";break;
case 3:
cout<<"Hari ke : "<<dino<<" = Rabu";break;
case 4:
cout<<"Hari ke : "<<dino<<" = Kamis";break;
case 5:
cout<<"Hari ke : "<<dino<<" = Jumat";break;
case 6:
cout<<"Hari ke : "<<dino<<" = Sabtu";break;
case 7:
cout<<"Hari ke : "<<dino<<" = Minggu";break;
default:
cout<<"Inputan eror, hanya 1 sampai 7 !!!";break;
}
}

main(){
HARI x;
x.hari();
}

[/sourcecode]

Posted on 00:28 by yusufruli

No comments