SHARE
TWEET

Muhammad Haidir

a guest Sep 16th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. public class operator2 {
  3.     public static void main(String[] args) {
  4.         Scanner input = new Scanner(System.in);
  5.             System.out.println("==Untuk Data Integer==");
  6.         int a,b,hasil;
  7.         System.out.print("Nilai a : ");
  8.         a = input.nextInt();
  9.         System.out.print("Nilai b : ");
  10.         b = input.nextInt();
  11.         hasil = a + b;
  12.         System.out.print("Penjumlahan : ");
  13.         System.out.println(a + "+" + b + "=" + hasil);
  14.         hasil = a - b;
  15.         System.out.print("Pengurangan : ");
  16.         System.out.println(a + "-" + b + "=" + hasil);
  17.         hasil = a * b;
  18.         System.out.print("Perkalian   : ");
  19.         System.out.println(a + "*" + b + "=" + hasil);
  20.         hasil = a / b;
  21.         System.out.print("Pembagian   : ");
  22.         System.out.println(a + "/" + b + "=" + hasil);
  23.         hasil = a % b;
  24.         System.out.print("Modulasi    : ");
  25.         System.out.println(a + "%" + b + "=" + hasil);
  26.  
  27.     Scanner input2 = new Scanner(System.in);
  28.             System.out.println("==Untuk Data Float==");
  29.         float c,d,hasilFloat;
  30.         System.out.print("Nilai c : ");
  31.         c = input2.nextFloat();
  32.         System.out.print("Nilai d : ");
  33.         d = input2.nextFloat();
  34.         hasilFloat = c + d;
  35.         System.out.print("Penjumlahan : ");
  36.         System.out.println(c +" "+ "+" +" "+ d +" "+ "=" +" "+ hasilFloat);
  37.         hasilFloat = c - d;
  38.         System.out.print("Pengurangan : ");
  39.         System.out.println(c +" "+ "-" +" "+ d +" "+ "=" +" "+ hasilFloat);
  40.         hasilFloat = c * d;
  41.         System.out.print("Perkalian   : ");
  42.         System.out.println(c +" "+ "*" +" "+ d +" "+ "=" +" "+ hasilFloat);
  43.         hasilFloat = c / d;
  44.         System.out.print("Pembagian   : ");
  45.         System.out.println(c +" "+ "/" +" "+ d +" "+ "=" +" "+ hasilFloat);
  46.         hasilFloat = c % d;
  47.         System.out.print("Modulasi    : ");
  48.         System.out.println(c +" "+ "%" +" "+ d +" "+ "=" +" "+ hasilFloat);
  49.     }
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top