Java Scrip Program Matematika

Saturday, May 10, 2014

Dibawah ini adalah scrip Java untuk pemula tentang program matematika sederhana.


package programmatematika;

import java.util.Scanner;

public class programmatematika {

      private static Scanner input;
     
      /**
       * @param args
       */
      public static void main(String[] args) {
            // TODO Auto-generated method stub

            input = new Scanner (System.in);
            System.out.println("==========================================");
            System.out.println("Selamat Datang di Program Matematika");
            System.out.println("==========================================");
            System.out.println("1. Penjumlahan Matematika");
            System.out.println("2. Perkalian Matematika");
            System.out.println(" ");
            System.out.println("Ketik Angka Untuk Memilih");
            System.out.print("Pilih Program Matematika");
            int pilih = input.nextInt();
            System.out.println("==========================");
           
            switch(pilih){
            case 1 :
                  System.out.print("Masukkan Nilai Pertama:");
                  int a = input.nextInt();
                  System.out.print("Masukkan Nilai Kedua:");
                  int b = input.nextInt();
                  int c = a + b;
                  System.out.println(" ");
                  System.out.println("==========================");
                  System.out.println ("Penjumlahan Matematika = " +c);
                  break;
                 
            case 2 :
                  System.out.print("MASUKKAN NILAI PERTAMA:");
                  double d = input.nextInt();
                  System.out.print("MASUKKAN NILAI KEDUA:");
                  double e = input.nextInt();
                  double f = d * e;
                  System.out.println("==========================");
                  System.out.println(" ");
                  System.out.println ("Perkalian Matematika = " +f);
                  break;
                  

Semoga bermanfaat..

0 comments:

Post a Comment