Kamis, 13 Desember 2012

operator aritmatika


 PROGRAM JAVA

program dengan menggunakan operator aritmatika, seperti berikut ini :

public class Aritmatika
{
    public static void main(String args[])
    {
    System.out.println("1 + 2 = " + (1 + 2));
    System.out.println("3 * 2 = " + (3 * 2));
    System.out.println("7 / 3 = " + (7 / 3));
    System.out.println("3 - 2 = " + (3 - 2));
    System.out.println("13% 5 = " + (13 % 5));
    System.out.println("");
    System.out.println("1 + 2 * 3 = " + (1 + 2 * 3));
    System.out.println("1 + 2 / 2 = " + (1 + 2 / 2));
    System.out.println("9 - 2 % 2 = " + (9 - 2 % 2));
    }
}

Hasil Output :

1 + 2 = 3
3 * 2 = 6
7 / 3 = 2
3 - 2 = 1
13% 5 = 3

1 + 2 * 3 = 7
1 + 2 / 2 = 2
9 - 2 % 2 = 9
Press any key to continue . . .

0 komentar:

Posting Komentar