Sunday, July 26, 2015

JAVA - Conversion

import java.util.*; public class Conversion { public static void main(String args[]) { int num=0, decimal=0, binary=0, octal=0, hexa=0, i=0, a=0, x=0, rem=0, remain=0, result=0, power=0, binNumba=0, der=0, counter=0, ctr=0; String output = ""; char let=0; char ch; String binNum =" "; String octNum =" "; String hexNum =" "; String str = ""; char dig[] = {'0', '1', '2', '3', '4', '5', '6', '7'}; char diig[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C' ,'D', 'E', 'F'}; Scanner conVert = new Scanner(System.in); System.out.println("1.Decimal to Binary"); System.out.println("2.Decimal to Octal"); System.out.println("3.Decimal to Hexadecimal"); System.out.println("4.Binary to Decimal"); System.out.println("5.Binary to Octal"); System.out.println("6.Binary to Hexadecimal"); System.out.println("7.Octal to Decimal"); System.out.println("8.Octal to Binary"); System.out.println("9.Octal to Hexadecimal"); System.out.println("Enter the number of the specific conversion you want to have:"); num=conVert.nextInt(); if(num == 1)//decimal-binary { System.out.println("Enter a decimal:"); decimal=conVert.nextInt(); if(decimal<=0) System.out.println("Can`t be converted!"); else { binNum = " "; while(decimal!=0) { binNum = decimal%2 + binNum; decimal=decimal/2; } } System.out.println("Binary is: "+ binNum); } else if(num == 2)//decimal-octal { System.out.println("Enter a decimal:"); decimal=conVert.nextInt(); if(decimal<=0) System.out.println("Can`t be converted!"); else { octNum = " "; while(decimal!=0) { octNum = decimal%8 + octNum; decimal=decimal/8; } } System.out.println("Octal is: "+ octNum); } else if(num == 3)//decimal-hexadecimal { String tempHex = " "; System.out.println("Enter a decimal:"); decimal=conVert.nextInt(); if(decimal<0 an="" be="" converted="" decimal="" else="" hexnum=" " system.out.println="" t="" while="">=0) { result = decimal%16; if(result == 10) { tempHex = "A"; } else if(result == 11) { tempHex = "B"; } else if(result == 12) { tempHex = "C"; } else if(result == 13) { tempHex = "D"; } else if(result == 14) { tempHex = "E"; } else if(result == 15) { tempHex = "F"; } else { tempHex = ""+result; } hexNum = tempHex + hexNum; decimal=decimal - (result * 16); } } System.out.println("Hexa is: "+ hexNum); } else if(num == 4)//binary-decimal { System.out.println("Enter a binary:"); binNumba=conVert.nextInt(); if(binNumba < 0 ) { System.out.println("Invalid Input! A Binary Number is Either 1 or 0:"); binNumba=conVert.nextInt(); } else { while(binNumba != 0) { rem = binNumba % 10; decimal += rem * Math.pow(2,power); binNumba = binNumba/10; power++; } } System.out.println("Decimal is:" +decimal); } else if(num == 5)//binary-octal { System.out.println("\nEnter a binary number:"); binNumba = conVert.nextInt(); if(binNumba < 0) { System.out.println("Invalid Input! A Binary Number is Either 1 or 0:"); binNumba = conVert.nextInt(); } else { while(binary != 0) { rem = binNumba % 10; decimal += rem * Math.pow(2,power); binNumba = binNumba/10; power++; } while(decimal != 0) { remain = decimal % 8; str = dig[remain] + str; decimal = decimal/8; } System.out.println("The octal is:" +str); } } else if(num == 6)//binary-hexa { System.out.println("Invalid Input! A Binary Number is Either 1 or 0:"); binNumba = conVert.nextInt(); if(binary < 0) { System.out.println("Invalid Input! A Binary Number is Either 1 or 0:"); binNumba = conVert.nextInt(); } else { while(binary != 0) { rem = binary % 10; decimal += rem * Math.pow(2,power); binary = binary/10; power++; } while(decimal != 0) { rem = decimal % 16; str = diig[rem] + str; decimal = decimal/16; } System.out.println("The hexadecimal is:" +str); } } else if(num == 7)//octal-decimal { System.out.println("Enter an octal number:"); octal = conVert.nextInt(); if(octal < 0) { System.out.println("Invalid Input! Enter an Octal Number:"); octal=conVert.nextInt(); } else { while(octal != 0) { rem = octal % 10; decimal += rem * Math.pow(8,power); octal = octal/10; power++; } System.out.println("The decimal is:" +decimal); } } else if(num == 8)//octal-binary { System.out.println("Enter an octal number:"); octal = conVert.nextInt(); if(octal < 0) { System.out.println("Invalid Input! Enter an Octal Number:"); octal=conVert.nextInt(); } else { while(octal != 0) { rem = octal % 10; decimal += rem * Math.pow(8,power); octal = octal/10; power++; } while(decimal != 0) { counter = decimal % 2; ctr = counter; decimal /= 2; output = ctr +""+ output; } System.out.println("The decimal is:" +output); } } else if(num == 9)//octal-hexa { System.out.println("Enter an octal number:"); octal = conVert.nextInt(); if(octal < 0) { System.out.println("Invalid Input! Enter an Octal Number:"); octal=conVert.nextInt(); } else { while(octal != 0) { rem = octal % 10; decimal += rem * Math.pow(8,power); octal = octal/10; power++; } while(decimal != 0) { rem = decimal % 16; str = diig[rem] + str; decimal = decimal/16; } System.out.println("The decimal is:" +str); } }
}
}

Friday, July 17, 2015

You Are Special

If you happen to ask yourself if you're special and your answer is NO and you don't even feel like you are, well, then you must've been wrong all this time. Being special is not always at anyone's comfort. It is when you look yourself in the mirror and there you are standing in front yourself beautifully shaped by the time. You are special with all of your flaws attached to your being.


Each individual is made by his own uniqueness. So, you as a person is different from the rest. The thing is, what makes you more special is that you are created by God Himself like His image and along with it is His love for you. You are special with whatever you are right now. It's so sad that some people have no idea that they are and they end up wasting the opportunity of being special.


God's greatest gift to us is the life that we have now. Life's journey is not easy, it's bumpy and it's a crooked road ahead and you got to learn how to ride with it. Along the way, you will be molded the way you never thought you would be. And as you look again in the mirror, there you see the man who have gone through a lot and yet still standing firm and humble. Basically, all of what you are or all of what you're made of makes you special. So acknowledge your being for you are one true special.

Saturday, July 11, 2015

And I'm So Addicted To 'Em

I am follower mates! You're one of the most beautiful thing animated. I love your language and your baldness and how you roll your big eyes.


Sunday, July 5, 2015

When It Rains

It's July and it's rainy season. I love the rain. I don't know exactly how I come to love it. It's just that it's serenity for me when it rains and I love every single sound of it when it drops. My friends and I used to get wet under the rain when we were younger and stroll every corner in the neighborhood. And it's been awhile that I haven't done something great like that. I have been wanting to do the same thing lately but don't have the chance to because i'm usually at work or at school or I'm at somewhere not at home when it rains, arrrrggghhh.

Lucky I am today, it's a Sunday, I'm at home and it's pouring so I took the chance to get myself soaked in the rain twice as in twice, yeheeeeeeeeeeeyyy, however, I wasn't able to capture a photo of myself getting soaked. And I don't know what to say except there were my happiest moments of the day.

google search

Custom Search