satriafu5710

Luas & Volume Kerucut Method Java

Dec 5th, 2020 (edited)
1,219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. package com.tutorial;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner userInput = new Scanner(System.in);
  9.         float phi = 3.14f;
  10.         float r, tinggi, s; // s = Panjang Garis Pelukis
  11.         float luasP, volume;
  12.  
  13.         System.out.println("\t Luas Permukaan & Volume Kerucut \n\n");
  14.         System.out.print(" Masukkan Jari-jari  : ");
  15.         r = userInput.nextFloat();
  16.  
  17.         System.out.print(" Masukkan Tinggi       : ");
  18.         tinggi = userInput.nextFloat();
  19.  
  20.         System.out.print(" Masukkan S            : ");
  21.         s = userInput.nextFloat();
  22.  
  23.         luasP = luasPermukaan(r, s);
  24.         System.out.print("\n Luas Permukaan : " + luasP);
  25.  
  26.         volume = volumeKerucut(r, tinggi);
  27.         System.out.print("\n Volume Kerucut : " + volume);
  28.     }
  29.  
  30.     public static float luasPermukaan(float r, float s) {
  31.         float phi = 3.14f;
  32.         float hasil = phi * r * (r + s);
  33.         return hasil;
  34.     }
  35.  
  36.     public static float volumeKerucut(float r, float t) {
  37.         float phi = 3.14f;
  38.         float hasil = 1 / (float) 3 * phi * r * r * t;
  39.         return hasil;
  40.     }
  41. }
Add Comment
Please, Sign In to add comment