hasan-mahmudz

HelloJava

Feb 2nd, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. package hellojava;
  2. import java.util.Scanner;
  3.  
  4. public class HelloJava {
  5.  
  6. public static void main(String[] args) {
  7. Scanner sn = new Scanner(System.in);
  8. Shape sp = new Shape();
  9.  
  10. System.out.print("Enter the size: ");
  11. sp.numPyramid(sn.nextInt());
  12. }
  13.  
  14. public static void split(int n){
  15. int rem, res = 1;
  16.  
  17. while(n != 0){
  18. rem = n % 10;
  19. res *= rem;
  20. n = n / 10;
  21. }
  22. System.out.println(res + " ");
  23.  
  24. }
  25.  
  26. public static void decToBin(int n){
  27. int rem = 0, i = 0;
  28. int[] a = new int[5];
  29.  
  30. while(n != 0){
  31. rem = n % 2;
  32. n = n / 2;
  33. a[i] = rem;
  34. i++;
  35. }
  36.  
  37. for(int j = i-1; j >= 0; j--){
  38. System.out.print(a[j]);
  39. }
  40.  
  41. System.out.println("");
  42.  
  43. }
  44.  
  45. }
Add Comment
Please, Sign In to add comment