Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1.  
  2. public class Test {
  3.    
  4.     static int HowManyDigitsAfterF(float Number){
  5.        
  6.         String floating = String.valueOf(Number);
  7.        
  8.         String[] y_split = floating.split("\\.");
  9.         int number;
  10.        
  11.         System.out.println(y_split[1]);
  12.         if (y_split[1].equals("0")){
  13.             number = 0;
  14.         }
  15.         else{
  16.             number = y_split[1].length();
  17.         }
  18.         return number;
  19.     }
  20.    
  21.     public static short CharacterCounterD(char s[], char c){
  22.         short count = 0;
  23.         try{   
  24.             String someString = null;
  25.             for(int i = 0; i < s.length-1; i++){
  26.                 String characters = Character.toString(s[i]);
  27.                
  28.                 someString += characters;
  29.             }
  30.            
  31.             for (int i = 0; i < someString.length(); i++)
  32.            
  33.             {
  34.                
  35.                 if (someString.charAt(i) == c) {
  36.                  
  37.                     count++;
  38.                
  39.                 }
  40.                
  41.             }
  42.            
  43.         }
  44.         catch(Exception e){
  45.             count = -4;
  46.         }
  47.         return count;
  48.     }
  49.    
  50.     public static String FiveDecimalPlaces(float Number){
  51.         String strDouble = String.format("%.5f", Number);
  52.         return strDouble;
  53.     }
  54.    
  55.     public static short DaysInAMonthD(short Month){
  56.         short days = 0;
  57.        
  58.         if(Month < 1 || Month > 12) {
  59.             days = -4;
  60.         }
  61.        
  62.         else{
  63.             if (Month <= 7){
  64.                
  65.                 if(Month%2 == 0){
  66.                     days = 30;
  67.                 }
  68.  
  69.                 else{
  70.                     days = 31;
  71.                 }
  72.                
  73.                 if (Month == 2){
  74.                     days = 29;
  75.                 }
  76.                
  77.                 if (Month == 7){
  78.                     days = 31;
  79.                 }
  80.             }
  81.             else if (Month >= 8){
  82.                
  83.                 if (Month == 2){
  84.                     days = 29;
  85.                 }
  86.                
  87.                 if(Month%2 == 0){
  88.                     days = 31;
  89.                 }
  90.  
  91.                 else{
  92.                     days = 30;
  93.                 }
  94.             }  
  95.         }
  96.         return days;
  97.        
  98.     }
  99.    
  100.     public static short FactorialD(short Number){
  101.         short i,fact=1;
  102.        
  103.         if(Number < 0){
  104.             fact = -4;
  105.         }
  106.         //It is the number to calculate factorial    
  107.         else{
  108.             for(i=1;i<=Number;i++){
  109.                 fact=(short) (fact*i);
  110.             }
  111.         }  
  112.         return fact;
  113.     }
  114.    
  115.  
  116.    
  117.    
  118.        
  119.    
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement