Skip to content

Instantly share code, notes, and snippets.

@bratawisnu
Last active December 11, 2018 05:43
Show Gist options
  • Save bratawisnu/be30bd9048f35c201f943c9529ee0fed to your computer and use it in GitHub Desktop.
Save bratawisnu/be30bd9048f35c201f943c9529ee0fed to your computer and use it in GitHub Desktop.
package binus;
import java.util.Scanner;
/**
*
* @author ucup
*/
public class Perhitungan {
public static void main(String[] args) {
int A, B;
Scanner sc = new Scanner(System.in);
System.out.print("Input bilangan A = ");
A = sc.nextInt();
System.out.print("Input bilangan B = ");
B = sc.nextInt();
int penjumlahan = A + B;
int pengurangan = A - B;
int perkalian = A * B;
int pembagian = A / B;
int modulo = A % B;
System.out.println("Hasil " + A + " + " + B + " = " + penjumlahan);
System.out.println("Hasil " + A + " - " + B + " = " + pengurangan);
System.out.println("Hasil " + A + " * " + B + " = " + perkalian);
System.out.println("Hasil " + A + " / " + B + " = " + pembagian);
System.out.println("Hasil " + A + " % " + B + " = " + modulo);
}
}
//Output
run:
Input bilangan A = 6
Input bilangan B = 2
Hasil 6 + 2 = 8
Hasil 6 - 2 = 4
Hasil 6 * 2 = 12
Hasil 6 / 2 = 3
Hasil 6 % 2 = 0
BUILD SUCCESSFUL (total time: 3 seconds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment