loreng

Inenaf

Jan 25th, 2021
406
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package inheritance2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Inheritance2 {
  6.     public static void main(String[] args) {
  7.         Dua p = new Dua();
  8.         p.perkalian();
  9.     }    
  10. }
  11.  
  12. class Satu{
  13.     public static int input(){
  14.         int output;
  15.         Scanner input = new Scanner(System.in);
  16.         output = input.nextInt();
  17.        
  18.         return output;
  19.     }
  20. }
  21.  
  22. class Dua extends Satu{
  23.     public static void perkalian(){
  24.         int nilai1, nilai2;
  25.         System.out.println("Nilai Pertama : ");
  26.         nilai1 = input();
  27.         System.out.println("Nilai Kedua : ");
  28.         nilai2 = input();
  29.         System.out.println("Hasil Perkaliannya dari "+ nilai1 + " dengan "+ nilai2 + " adalah "+ (nilai1 * nilai2));
  30.     }
  31. }
RAW Paste Data