Advertisements

Aatul Palandurkar

Archive for the ‘NetBeans IDE Source Code’ Category

Objectives :

  • How to convert Decimal to Hexadecimal in Java?

 

Java Program to convert Decimal values to Hexadecimal values : 


import java.util.Scanner;

public class DecimalToHexadecimal {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Enter decimal number you like: ");
int deci = input.nextInt();

System.out.println("The hexadecimal number for decimal "
+ deci + " is " + convert(deci));
}

public static String convert(int decimal) {
String hex = "";

while (decimal != 0) {
int hexValue = decimal % 16;
hex = toHexadecimal(hexValue) + hex;
decimal = decimal / 16;
}

return hex;
}

public static char toHexadecimal(int hexValue) {
if (hexValue <= 9 && hexValue >= 0) {
return (char) (hexValue + '0');
} else {
return (char) (hexValue - 10 + 'A');
}
}
}

Output :
Enter decimal number you like: 1234
The hexadecimal number for decimal 1234 is 4D2

Advertisements

Objectives :

  • Convert Decimal number to Roman number
  • Convert Decimal numeral to Roman numeral
  • How to convert a decimal number to roman number
  • Write a program that converts a decimal number to Roman number.
  • Write a program that converts a decimal number to Roman number. Decimal Number is accepted using Scanner class at the time of execution.
  • Write a program that converts a decimal number to Roman number. Decimal Number is accepted as command line input at the time of execution.

 

Program : 

Java program that converts a decimal number to Roman number. Decimal Number is accepted using Scanner class at the time of execution.


&nbsp;

import java.util.Scanner;

public class DecimalToRoman {

private static String toRoman(int num) {
String[] romanCharacters = { "M", "CM", "D", "C", "XC", "L", "X", "IX", "V", "I" };
int[] romanValues = { 1000, 900, 500, 100, 90, 50, 10, 9, 5, 1 };
String result = "";

for (int i = 0; i < romanValues.length; i++) {
int numberInPlace = num / romanValues[i];
if (numberInPlace == 0) continue;
result += numberInPlace == 4 && i > 0? romanCharacters[i] + romanCharacters[i - 1]:
new String(new char[numberInPlace]).replace("\0",romanCharacters[i]);
num = num % romanValues[i];
}
return result;
}

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number : ");
int decimal = scanner.nextInt();
System.out.println(toRoman(decimal));
}

}

Output :

Enter a number : 1234

MCCXXXIV

Java program that converts a decimal number to Roman number. Decimal Number is accepted as command line input at the time of execution.


public class DecimalToRoman {

private static String toRoman(int num) {
String[] romanCharacters = { "M", "CM", "D", "C", "XC", "L", "X", "IX", "V", "I" };
int[] romanValues = { 1000, 900, 500, 100, 90, 50, 10, 9, 5, 1 };
String result = "";

for (int i = 0; i < romanValues.length; i++) {
int numberInPlace = num / romanValues[i];
if (numberInPlace == 0) continue;
result += numberInPlace == 4 && i > 0? romanCharacters[i] + romanCharacters[i - 1]:
new String(new char[numberInPlace]).replace("\0",romanCharacters[i]);
num = num % romanValues[i];
}
return result;
}

public static void main(String[] args) {
if(args.length<1 || args.length>1){
System.out.println("Wrong input");
}else{
String number = args[0];
int decimal = Integer.parseInt(number);
System.out.println(toRoman(decimal));
}
}

}

NetBeans IDE How-to : Atul Palandurkar : Packt Publishing, UK

NetBeans IDE How-to : Atul Palandurkar : Packt Publishing, UK

I was asked to write a book for Java Application Development using NetBeans IDE by PACKT Publishing, UK which is one of the leading technology books publishers in world. It will be a great experience to work with the great publishing house and their team. Thanks a lot Packt & Team.

I know, Java and NetBeans community will definitely accept the book with a grand welcome. The book is intended for Java Developers who are not aware of NetBeans IDE or those who have experience of Java development but have not used NetBeans for development of Java applications. This book can be referred by novice also to learn Java and Java application development using NetBeans IDE very easily.

My outline (contents) was selected out of few other authors and then after we signed the contract, now the book is complete and very soon the book will hit the market in different formats by the publisher in March 2013.

I just love it, I have tried my best in writing this book and to make it easier for novice to experts. It was a great pleasure working with Packt Team.

You will learn many things from this book such as :

  • Use NetBeans IDE for Java technologies
  • Develop a HelloWorld application with NetBeans IDE
  • Explore the layout of NetBeans IDE
  • Develop different Java applications in NetBeans
  • Use the Visual Designer
  • Design Java projects
  • Develop web applications using NetBeans IDE
  • Add and handle images in your application
  • Write interfaces in NetBeans IDE
  • Handle exceptions in NetBeans IDE
  • Deploy UI applications

You can order the book to avail huge discount. Instead of Packt Publishing the NetBeans IDE How-to book is also available on Amazon, Amazon UK, Barnes & Noble, Safari Books Online too.

You can buy and download the book in different formats such as e-book (pdf), e-pub, kindle book, etc.

Buy NetBeans IDE How-to Book

I hope you will like the book. After reading, please mail me your reviews.

You can book your copy from following links :

Get your copy now and start developing professional applications within few minutes.


Advertisements

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 8,341 other followers

Tweets

%d bloggers like this: