Senin, 13 Juni 2011

C++ : Between 3 Largest Numbers Determining Integer in C++

download

I. ALGORITHM

{Read three integers, determine the largest number among threenumbers and display it to screen}


DECLARATION

x, y, z: integer


DESCRIPTION
read (x, y, z)
if (x> y) and (x> z) then write ('The biggest number is = x)
else if (y> x) and (y> z) then write (the largest number is = y)
else write (the largest number is z)
end if

II. Source code in C + +

# include
# include

class appeal {
friend istream& operator >> ( istream&, vs& );
public:
appeal (){};
void compare () {
if ((x> y) & & (x> z))
cout <<"the largest number:" <else if ((y> x) & & (y> z))
cout <<"the largest number:" <else
cout <<"the largest number:" <}
private:
int x, y, z;
};

istream& operator>> (istream& in, appeals& number) {
cout <<"Numbers first =";
in>> bilangan.x;
cout <<"The second number =";
in>> bilangan.y;
cout <<"third number =";
in>> bilangan.z;
return ins;
}

int main () {
appeal number;
cin>> number;
bilangan.bandingkan ();

return 0;
}

download

C++ : Algorithms and Programming Calculating Triangle Area

Download

I. ANALYSIS
Input: t (high) area = l * a / 2

II. ALGORITHM


{Reading the real data in the form of long triangular base (a) and high triangle (t) and calculate the extent of the length of the base and a certain high. Area of ​​triangle is calculated by the formula L = 1 / 2 at. The value L in print as the output to the output device.}
DECLARATION a : real {long triangular base, in units of cm} t : real {height triangle, in units of cm} L : real {area of ​​the triangle} DESCRIPTION read (a) read (t) L <- (a * t) / 2 write (L)
III. Source code in C + +
# Include # Include
class circle { friend ostream& operator <<(ostream&, circle&); friend istream& operator>> (istream&, circle&); public: hitung_keliling void () {circumference = 2 * pi * r;} hitung_luas void () {area = pi * r * r;} private: int r; float perimeter, area; };
istream & operator>> (istream& in, circle& A) { cout <<"Finger - finger circle:"; in>> A.r; return is; }
ostream & operator <<(ostream& out, circles& A) { A.hitung_keliling (); A.hitung_luas (); out <<"Circumference =" <download

Minggu, 12 Juni 2011

Kriptografi AMD5

download source code kriptografi AMD5

   Kriptografi telah dikenal dan dipakai cukup lama sejak kurang lebih tahun 1900 sebelum masehi pada prasasti-prasasti kuburan. Kriptografi sendiri berasal dari kata “Crypto” yanng berarti rahasia dan “graphy” yang berarti tulisan. Jadi, dapat dikatakan kriptografi adalah tulisan yang tersembunyi. Dengan adanya tulisan yang tersembunyi ini, orang-orang yang tidak mengetahui bagaimana tulisan tersebut disembunyikan tidak akan mengetahui bagaimana cara membaca maupun menerjemahkan tulisan tersebut. William Stallings mendefinisikan kriptografi sebagai “the art and science of keeping messages secure”.

    Kriptografi menjadi dasar bagi keamanan komputer dan jaringan karena yang menjadi pokok dari fungsi komputer dan jaringan adalah data ataupun informasi. Komputer dan jaringannya menjadi sarana bagi distribusi data dan informasi, maka data dan informasi tersebut harus diamankan agar hanya orang-orang yang berhak mengaksesnya yang dapat mengetahui maupun menggunakan data tersebut. Salah satu cara yang paling banyak digunakan dalam mengamankan data adalah dengan kriptografi. Data-data tersebut diamankan dengan sedemikian rupa oleh pengirim sehingga orang lalin tidak dapat mengenali data tersebut. Hal ini lebih dikenal dengan nama proses enkripsi. Data atau pesan yang asli sering disebut sebagai plaintext dan data yang telah dienkripsi disebut sebagai chipertext ata menurut terminologi yang lebih tepat enchiper.

    Data yang telah dienkripsi disebut chipertext karena data asli (plaintext) telah mengalami proses di dalam sebuah algoritma kriptografi atau lebih dikenal dengan nama chiper. Kebalikannya, proses merubah pesan yang telah dienkripsi (chipertext) menjadi pesan asli (plaintext) disebut sebagai proses dekripsi atau dechiper.

Source code nya dapat di download di sini

JAVA : Konstanta Java


download materi konstanta

At Java, we utilize key word (keyword) final to point out konstanta.

example:




lingkaran.java
public class lingkaran {
   public static void main(String args[]) {
       final double PHI = 3.14;
       double radius = 100;
       System.out.println(“keliling lingkaran berjari -             jari”+radius+”adalah”+(2*PHI*radius));
   }
}


Final key word betoken point application goes to variable at do once only, point afterwards at variable it can't at changes eternally.

convention:
Name konstanta is uppercase the lot, e.g.:



final double PHI = 3.14
final double CM_PER_INCHI = 2.54;

Often at Java, konstanta applies to all method / function at one class. Konstanta this ordinary at konstanta's mention brazes (class constant)  We can make konstanta class with static's key word final.

example:




Lingkaran.java
public class lingkaran {
   public static final double PHI = 3.14;
   
   static void test() {
   lingkaran t = new lingkaran();

   double radius = 100;
   System.out.println(“keliling lingkaran berjari - jari”+radius+”adalah”+t.calcCircumference(radius));
   System.out.println(“keliling lingkaran berjari - jari”+radius+”adalah”+t.calcArea(radius));
   }
   public static void main(String args[]){
      test();
   }
   static double calcCircumference(double r){
      return (2*PHI*r);
   }
   static double calcArea(double r){
      return (PHI*r*r);
   }

konstanta's definition at do outside main's method(). Thus, konstanta can at utilizes at other methods at same class.

More again, konstanta at samples at declaration utilizes access modifier well worth public, therefore methods at even other class gets to utilize konstanta by points konstanta's name by calls class name as follows:



<nama kelas>.<nama konstanta>.

On example upon konstanta PHI was pointed to utilize identifier following:



Lingkaran.PHI

download  materi konstanta

JAVA : Keyword and Literal Java


download materi keyword and literal

KEYWORD

keyword is identifier that at utilizes Java for a special aim. keyword's list Java as follows:












Abstract
Double
Int
Super
Boolean
Else
Interface
Switch
Break
Extends
Long
Synchronized
Byte
False
Native
This
Byvalue
Final
New
Threadsafe
Case
Finally
Null
Throw
Catch
Float
Package
Transient
Char
For
Private
True
Class
Goto
Protected
Try
Const
If
Public
Void
Continue
Implements
Return
While
Default
Import
Short
Do
instanceof
static

We may not utilize keyword as identifier.


literal

Bigger writing for variable is important, literal at Java consists:

1. number
2. character
3. string

Number consisting of integer (integer)  number floats (floating - pont)  and boolean. Boolean was looked on by number. boolean's point to true and false at looks on as 1 and 0. Character always point to Unicode's character. string contains character-string.
download  materi keyword and literal

JAVA : Integer Operator Java


download materi integer operator

operating binary integer operator on integer couple. Following is binary integer operator table.














Deskripsi
Operator
Increase
+
Cut back
-
multiple
*
division
/
Rest for
%
Bitwise AND
&
Bitwise OR
|
Bitwise XOR
^
Left-shift
<< 
Right-shift
>> 
Zero-fill-right-shift
>>> 

sum operator, cut back, multiple, and division(+, -, *, /) doing operation as on aritmatika integer.

Highlight that needs at cermati is make the point division operator work with integer transfer. Division operator transfer integer quotient. If division results rest for therefore modulus operator(%) can at utilizes to get rest point for that.

Following is program Arithmetic to point out aritmatika's operator job binary:




Arithmatic.java
package arithmatic;

public class Arithmatic {
   public static void main (String args[]) {
       int x = 17, y = 5;

       System.out.println(“x =” + x);
       System.out.println(“y =” + y);
       System.out.println(“x + y” + (x+y));
       System.out.println(“x - y” + (x-y));
       System.out.println(“x * y” + (x*y));
       System.out.println(“x / y” + (x/y));
       System.out.println(“x % y” + (x%y));
   }
}


Instruction:

javac Arithmetic.java
Arithmetic's Java

Result Programs:

x = 17
y. = 5
x + y. = 22
x y. = 12
x * y. = 85
x / y. = 3
x % y. = 2

Quotient x / y. which is 17 / 5 results 3. modulus Operation x % y. which is 17 % 5 result 2 (which is rest for integer).

matenatika's ala division with zero don't at defines. Java treats this division by throws / result runtime exeception. We will study exeception alone ala.

bitwise AND's operator, OR, and XOR

bitwise and's operator, or, and xor(&, |, and ^) act on individual bit bit integer. This operator sometime beneficent while integers that at utilizes as field's bit.

example:
Number purpose as field's bit is subject to be declaration a group flag binary number. One number int that mempresentasikan can until 32 flag that different because int at deep keeping 32 bits.




Bitwise.java
package bitwise;

public class Bitwise {
   public static void main (String args[]) {
       Int x = 5, y = 6;
       System.out.println(“x =” + x);
       System.out.println(“y =” + y);
       System.out.println(“x & y” + (x&y));
       System.out.println(“x | y” + (x|y));
       System.out.println(“x ^ y” + (x^y));
  }
}


Instruction:

javac Bitwise
Bitwise's Java

Result programs:

x = 5
y. = 6
x & y. = 4
x | y. = 7
x ^ y. = 3

To understand output result, we shall understand representasi int's number in two' s complement.

Shift operator
Looking at samples following:

x<< 3;
y.>> 7;
z.>>> 2;

On first example, variable individual bit bit integer x is angled to left as much three positions. On second example, bit bit of y. at angles to right as much position sevens. On example drding to point out z. at angles as much 2 positions, with give duck's egg on two left utmost positions.

Looking at programs following:




Shift.java
package shift;

public class Shift {
   Public static void main (String args[]){
       Int x = 7;
       System.out.println(“x =” + x);
       System.out.println(“x >> 2 =” + (x >>> 2));
       System.out.println(“x << 1 =” + (x << 1));
       System.out.println(“x >>> 1 =” + (x >>> 1));
   }
}


Instruction:

javac Shift.java
Shift Java

Result Programs:

x = 7
x>> 2 = 1
x<< 1 = 14
x>>> 1 = 3
download  materi integer operator

ALL INFORMATION Copyright © 2011 | Template created by O Pregador | Powered by Blogger