Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test {
- static int HowManyDigitsAfterF(float Number){
- String floating = String.valueOf(Number);
- String[] y_split = floating.split("\\.");
- int number;
- System.out.println(y_split[1]);
- if (y_split[1].equals("0")){
- number = 0;
- }
- else{
- number = y_split[1].length();
- }
- return number;
- }
- public static short CharacterCounterD(char s[], char c){
- short count = 0;
- try{
- String someString = null;
- for(int i = 0; i < s.length-1; i++){
- String characters = Character.toString(s[i]);
- someString += characters;
- }
- for (int i = 0; i < someString.length(); i++)
- {
- if (someString.charAt(i) == c) {
- count++;
- }
- }
- }
- catch(Exception e){
- count = -4;
- }
- return count;
- }
- public static String FiveDecimalPlaces(float Number){
- String strDouble = String.format("%.5f", Number);
- return strDouble;
- }
- public static short DaysInAMonthD(short Month){
- short days = 0;
- if(Month < 1 || Month > 12) {
- days = -4;
- }
- else{
- if (Month <= 7){
- if(Month%2 == 0){
- days = 30;
- }
- else{
- days = 31;
- }
- if (Month == 2){
- days = 29;
- }
- if (Month == 7){
- days = 31;
- }
- }
- else if (Month >= 8){
- if (Month == 2){
- days = 29;
- }
- if(Month%2 == 0){
- days = 31;
- }
- else{
- days = 30;
- }
- }
- }
- return days;
- }
- public static short FactorialD(short Number){
- short i,fact=1;
- if(Number < 0){
- fact = -4;
- }
- //It is the number to calculate factorial
- else{
- for(i=1;i<=Number;i++){
- fact=(short) (fact*i);
- }
- }
- return fact;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement