Tips for heathy life

Tips for heathy life

Minggu, 02 November 2008

Dispay array in C++ programme

I want to share program that display array in C++. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

#include <>
#include <>
#include <>

void main ( )
{
clrscr( );
int nilai[6] = {4,2,3,5,1,6};
int i;

for(i=1;i<6 i=""><<"="; cout <<:i endl="">

How to display 10 integer and summation of that integer in C++?


I want to share how to display 10 integer and summation. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

---------------------
#include
#include
void main ( )
{
clrscr( );
int i,x,jml;
int index[10] = {1,2,3,4,5,6,7,8,9,10};
for(i=1;i<11 br="" i=""> {
cout<<"Input integer number- "< cin< jml=x;
jml=jml+x;
cout<<"Total of integer = "< }
getch( );
}

How make program that calculates flat wake in C++?

I want to share program that calculate flat wake in C++. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

--------
#include
#include

void main ( )
{
const float phi=3.14;
float r,a,t,kell,luas;
int kode;
char pilih;

awal :
cout<<"||======================================||"<<<"||Program menghitung rumus bangun datar ||"<<<"||======================================||"<<<"\n 1. Keliling Lingkaran "<<<"2. Luas Segitiga "<<<"\n Pilihan anda adalah (1..2) = "; cin>>kode;
switch (kode)
{
case 1 :
cout<<"Anda memilih nomor 1 yaitu menghitung keliling lingkaran"; cout<<"\nMasukkan jari-jari = "; cin>>r;
kell=2*phi*r;
cout<<"\nKeliling Lingkaran = "<<<<"Anda memilih nomor 2 yaitu menghitung luas segitiga"; cout<<"\nMasukkan alas = "; cin>>a;
cout<<\nMasukkan tinggi = "; cin>>t;
luas=a*t*0.5;
cout<<"\nLuas Segitiga = "<<<<"\nMaaf anda memasukkan kode yang salah"<<<"Ingin mengulang lagi [Y/T] = "; cin>>pilih;
if ((pilih=='Y'||(pilih=='y'))
{
goto awal;
}
clrscr ( );
cout<<"\nGoodbye!!!";
}
goto awal;
getch ( );
}

How make display date in pascal?


I want to share program that display date in Pascal. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

Date Programme (input,output);

uses wincrt;
const
teks='Input date on mm dd yy(0 0 0 to stop)';
typestring=string[20];
arraytipestring=array[1..12] of tipestring;
var
month,day,year:integer;
outputdate:tipestring;
namemonth:arraytipestring;
Procedure displaynamemonth(var namemonth:arraytipestring);

begin
namemonth[1] :='Januari';
namemonth[2] :='Februari';
namemonth[3] :='Maret';
namemonth[4] :='April';
namemonth[5] :='Mei';
namemonth[6] :='Juni';
namemonth[7] :='Juli';
namemonth[8] :='Agustus';
namemonth[9] :='September';
namemonth[10] :='Oktober';
namemonth[11] :='November';
namemonth[12] :='Desember';
end;

Function DateConvert(M,D,Y:integer):

typestring;

var
day,year:tipestring;

begin
str(D,Day);
str(Y:2,year);
if year[1]:=' ' then year[1]:='0';
year:='19' + year;
if (m>=1) and (m<=12) then
DateConvert:=namemonth[M] + day + ' ' + year
else
DateConvert:='Wrong Date';
end;

Begin
displaynamemonth(namemonth);
write(teks);
readln(month,day,year);
while month and day <> 0 do
begin
resultdate:= DateConvert (month,day,year);
writeln('date numeric = ',month:3,day:3,year:3);
writeln('alpha numeric = ',hasildate);
write(teks);
readln(month,day,year);
end.

BUBLE ASCENDING in Pascal

Program Buble_Ascending_09;

uses wincrt;

var
i,k, temp:integer;
L:array[1..5] of integer;
flag:boolean;

begin
clrscr;
L[1]:=1;
L[2]:=50;
L[3]:=10;
L[4]:=3;
L[5]:=2;

flag:=false;
i:=1;
while (i<5 and="" br="" do="" flag="" not=""> begin
flag:=true;
for k:=5 downto 1 do
if(L[k] begin
temp:=L[k];
L[k]:=L[k-1];
L[k-1]:=temp;
flag:=false;
end;
inc(i);
end;

begin
for i:=1 to 5 do
writeln(L[i],' ');
writeln;
end;

end.

STACK in Pascal

Program ArrayStack;

uses wincrt;

const
max=10;

var
Top,i:byte;
Pil,temp,e:char;
Stack:array [1..max] of char;

Procedure PushAnim;

begin
for i:=1 to 18 do
begin
gotoxy(23+i,7);write(temp);{delay(30); }
gotoxy(23,7);clrEol;
end;

for i:=1 to 14-top do
begin
{delay(30); }
gotoxy(41,6+i);write(' ');
gotoxy(41,7+i);write(temp);
end;
end;

Procedure PopAnim(temp:char);

begin
for i:=1 to 14-top do
begin
{delay(30); }
gotoxy(41,22-i-top);write(temp);{delay(30); }
gotoxy(41,21-i-top);ClrEol;
end;
end;

Procedure Push(e:char);

begin
inc(top);
Stack[top]:=e;
PushAnim;
end;

Procedure Pop(e:char);

begin
if top <> 0 then
begin
e:=stack[top];PopAnim(e);
dec(top);
end else
begin
gotoxy(1,7);write(' Stack Telah Kosong ');readkey;
gotoxy(1,7);ClrEol;
end;
end.

begin
clrscr;
writeln(' ANIMASI STACK ');
writeln(' 1. Push ');
writeln(' 2. Pop ');
writeln(' 3. Quit ');
writeln(' Pilihan [1/2/3] = ');
gotoxy(59,6);write(' \ ');
gotoxy(59,8);write(' / ');
gotoxy(37,10);write(' \ /');
for i:= 1 to 11 do
begin
gotoxy(38,10+i);
if i= 11 then write(' |_______________________________| ') else
write(' |........................| ');
end;
top:=0;
repeat
gotoxy(19,5);ClrEol;
Pil:=readkey;write(Pil);
if Pil='1' then
begin
if top <> max then
begin
gotoxy(1,7);write('Masukkan suatu huruf = ');
temp:=readkey;write(temp);
Push(temp);
gotoxy(1,7);CLrEol;
end else
begin
gotoxy(1,7);write(' Stack telah penuh' );
readkey;
gotoxy(1,7);ClrEol;
end;
end else
if Pil='2' then Pop(temp);
until Pil='13';
end.

ARRAY in Pascal

uses wincrt;

var
data:array[1..7,1..7] of byte;
baris,kolom:integer;

begin

for baris:=1 to 7 do
begin
for kolom:=1 to 7 do
if (baris=kolom) or (baris+kolom=8) or (baris=4) or (kolom=4) then

data[baris,kolom]:=0
else
data[baris,kolom]:=1;
end;

for baris:=1 to 7 do
begin
for kolom:=1 to 7 do
write(' ',data[baris,kolom]);
writeln;
end;
end;

Jumat, 31 Oktober 2008

Selection Operator 1 in Java

String status = "";
int grade = 80;
//mendapatkan status pelajar
status = (grade >= 60)?"Passed":"Fail";
//print status
System.out.println( status );

Logical NOT Operator in Java

boolean val1 = true;
boolean val2 = false;
System.out.println(!val1);
System.out.println(!val2);

Relation Operator

I want to share about relation operator. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

----------------
int i = 37;
int j = 42;
int k = 42;
System.out.println("Nilai variabel...");
System.out.println(" i = " + i);
System.out.println(" j = " + j);
System.out.println(" k = " + k);
//lebih besar dari
System.out.println("Lebih besar dari...");
System.out.println(" i > j = " + (i > j)); //false
System.out.println(" j > i = " + (j > i)); //true
System.out.println(" k > j = " + (k > j)); //false
//lebih besar atau sama dengan
System.out.println("Lebih besar dari atau sama dengan...");
System.out.println(" i >= j = " + (i >= j)); //false
System.out.println(" j >= i = " + (j >= i)); //true
System.out.println(" k >= j = " + (k >= j)); //true
//lebih kecil dari
System.out.println("Lebih kecil dari...");
System.out.println(" i < j = " + (i < j)); //true
System.out.println(" j < i = " + (j < i)); //false
System.out.println(" k < j = " + (k < j)); //false
//lebih kecil atau sama dengan
System.out.println("Lebih kecil dari atau sama dengan...");
System.out.println(" i <= j = " + (i <= j)); //true
System.out.println(" j <= i = " + (j <= i)); //false
System.out.println(" k <= j = " + (k <= j)); //true
//sama dengan
System.out.println("Sama dengan...");
System.out.println(" i == j = " + (i == j)); //false
System.out.println(" k == j = " + (k == j)); //true
//tidak sama dengan
System.out.println("Tidak sama dengan...");
System.out.println(" i != j = " + (i != j)); //true
System.out.println(" k != j = " + (k != j)); //false

VERIFIED PASSWORD and USER NAME in Java SE

String user="";
String pwd="";
user = JOptionPane.showInputDialog("Masukkan username anda : ");
pwd = JOptionPane.showInputDialog("Masukkan password anda: ");
String msg = "Welcome to java programming language, " + user + " !";
String msg2 = " Verfikasi password anda: " + "password anda = "+pwd;
JOptionPane.showMessageDialog(null, msg);
JOptionPane.showMessageDialog(null, msg2);

Kamis, 30 Oktober 2008

Find for the last word from JOPTIONPANE version in J2SE



I want to share how to Find for the last word from JOPTIONPANE version. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.


import javax.swing.JOptionPane;



public class Main {


public Main() {
}


public static void main(String[] args) {

String world1= "";
String world2= "";
String world3= "";
world1=JOptionPane.showInputDialog("Enter world 1");
world2=JOptionPane.showInputDialog("Enter world 2");
world3=JOptionPane.showInputDialog("Enter world 3");
String msg= world1 +" "+ world2 +" " + world3;
JOptionPane.showMessageDialog(null,msg);
}

}

Find for the last word from BUFFEREDREADER version in J2SE



I want to share how to Find for the last word from BUFFEREDREADER version in J2SE. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JOptionPane;

public class GetInputFromKeyboard {

public static void main(String[] args) throws IOException {
BufferedReader dataIn = new BufferedReader(new InputStreamReader (System.in));

String word1 = "",word2 ="", word3="";

System.out.println("Enter Word 1 : ");
word1=dataIn.readLine();
System.out.println("Enter Word 2 : ");
word2=dataIn.readLine();
System.out.println("Enter Word3 : ");
word3=dataIn.readLine();
System.out.println(word1 +" "+ word2+" "+ word3);


}

}

Average FIGURE FROM THREE in J2SE



I want to share how to Average FIGURE FROM THREE in J2SE. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

int number1 = 10;
int number2 = 20;
int number3 = 45;
int rata;
rata = ( number1+number2+number3)/3;
System.out.println("Rata-rata = " + rata );