Home Answers Viewqa Java-Interview-Questions converting From Hexadecimal to Decimal System

 
 


atoa
converting From Hexadecimal to Decimal System
2 Answer(s)      2 years and 10 months ago
Posted in : Java Interview Questions

Write a program in Java user is required to enter a number system XVI and turn it into the decimal system, using
StringBuffer
View Answers

July 12, 2010 at 3:41 PM


Hi Friend,

Try the following code:

import java.util.*;
public class RomanToDecimal {
public static void main(String args[]) {
int decimal=0;
Scanner input=new Scanner(System.in);
System.out.println("Enter a Roman Number: ");
String roman = input.next();
String romanNumeral = roman.toUpperCase();
int x = 0;
do{
char convertToDecimal = roman.charAt(x);
switch(convertToDecimal){
case 'M':
decimal += 1000;
break;

case 'D':
decimal += 500;
break;

case 'C':
decimal += 100;
break;

case 'L':
decimal += 50;
break;

case 'X':
decimal += 10;
break;

case 'V':
decimal += 5;
break;

case 'I':
decimal += 1;
break;
}
x++;
}while(x<romanNumeral.length());
System.out.println("Decimal Number is: " + decimal);
}
}

Thanks









Related Pages:
converting From Hexadecimal to Decimal System - Java Interview Questions
converting From Hexadecimal to Decimal System  Write a program in Java user is required to enter a number system XVI and turn it into the decimal system, using StringBuffer  Check this link. http://www.roseindia.net
conversion from decimal to hexadecimal and vice versa
conversion from decimal to hexadecimal and vice versa  can i get the code for converting decimal to hexadecimal   Here is a code that converts decimal to hexadecimal. import java.io.*; public class
decimal to hexadecimal
decimal to hexadecimal  using array in java convert decimal to hexadecimal.   Hi, Please see the example Convert Decimal to Hexadecimal. Thanks
Convert Hexadecimal to Decimal
Convert Hexadecimal to Decimal     ... a hexadecimal number into decimal. Code Description: This program takes a hexadecimal...: hexadecimal and 16. It converts a hexadecimal number into a decimal number. 
Convert Decimal to Hexadecimal
Convert Decimal to Hexadecimal     ... into hexadecimal. The java.lang package provides the functionality to convert a decimal... a decimal number at console and converts it  into the hexadecimal format using
converting decimal to base 32
converting decimal to base 32  procedure for converting decimal to base 32   CREATE PROCEDURE RTCONVERSION ( @valueToConvert int, @convertedValue varchar(20) out ) AS declare @counter int; declare @num int; declare @x
Convert Binary to Hexadecimal
Convert Binary to Hexadecimal     ... into hexadecimal.  The java.lang package provides the functionality to convert the binary data into hexadecimal.  Description of the program: This program takes
temperature converting
charts showing: The Fahrenheit equivalents of all Celsius temperatures from 0... Fahrenheit temperatures from 32 to 212 degrees in 10 degree intervals Both columns in each chart should be printed to one decimal place Print the charts
I converting binary to decimal and vice versa
I converting binary to decimal and vice versa  can i ask for the codes in converting binary to decimal and decimal to binary to be run in one program with repeat.. pls. help me! i badly need the codes by monday!! pls
Converting Numbers to Strings
Java: Converting Numbers to Strings Vanilla Java: Converting numbers... documented, they are a better second choice. Converting Anything to String... control over the formating of numbers (number of decimal places, scientific
Convert integer type data into binary, octal and hexadecimal
Convert integer type data into binary, octal and hexadecimal... will learn how to convert an integer type data into binary, octal and hexadecimal. The  java.lang package provides the facility for converting the data integer
Converting Anything to String
Java: Converting Anything to String Summary: Converting any data... control using some of the alternatives. Converting numbers to strings - See Converting Numbers to Strings There are many specialized issues with regard
how to convert all the pixel value to hexadecimal and from hexadecimal to binary in vb.net
how to convert all the pixel value to hexadecimal and from hexadecimal... is not available so that i selected as java.first i need to store the pixels in 2d array .from that i need to convert all the pixel values into hexadecimal how it can be done
hexadecimal conversion java compilation - UML
hexadecimal conversion java compilation  write a simple program (in any language of your choice) that accepts a program of 12 binary digits) and converts them to both decimal and hexadecimal as outputs  Hi Friend
SQL Decimal
an example from 'SQL Decimal'. To understand and grasp the example we create... SQL Decimal       SQL Decimal is used to specify the values in decimal datatype. The Decimal datatype
Convert Hexadecimal number into Integer
to convert hexadecimal data into integer. The java.lang package provides the functionally to convert the hexadecimal data into an integer type data.  Code... (using the keyboard) and converts the hexadecimal data into an integer type data
Converting a Filename to a URL
Converting a Filename to a URL     ... of the URL class, is used to get the file name from the URL. Here is the code...\ConstructFileNamePath\ConstructFileNamePath.txt (The system cannot find the path specified
Java Conversion
to Hexadecimal In this section, you will learn to convert decimal data into hexadecimal. The java.lang package provides the functionality to convert a decimal number into hexadecimal. Convert Binary to Decimal In this section
Convert Hexadecimal into Binary and Long
Description: This program helps you in converting the hexadecimal data... Convert Hexadecimal into Binary and Long   ... the hexadecimal data into the binary and long format. The java.lang package provides
Java Glossary Term - D
that is used for converting the decimal numbers into Strings. This class is also...; to the number of decimal places.   do while loop In java a do... different. SGML is the language from which XML was derived. Document type
decimal to base 36
decimal to base 36  procedure for converting decimal to base 36   CREATE PROCEDURE RTCONVERSION ( @valueToConvert int, @convertedValue varchar(20) out ) AS declare @counter int; declare @num int; declare @x int
Convert Byte to Hexadecimal
Convert Byte to Hexadecimal     ... into a hexadecimal number. The package java.lang provides the functionality for this conversion. Code Description: This program takes a byte number from console
converting field to text sql
converting field to text sql  I wanted to convert the field to TEXT in SQL.. is it possible?   SQL - Converting the field to TEXT works SELECT CONVERT(TEXT,fld_name) FROM TABLE_NAME   SQL - Converting
Converting a NSString into NSDate
Converting a NSString into NSDate  hello. How can I create a NSDate object out of it and then get different components like day, month, date, year from it. I have date string: Tuesday, October 19, 2010
Convert Decimal to Integer
in converting a decimal type data into an integer. The parseInt() method gets... Convert Decimal to Integer       In this section, you will learn to convert  a decimal number
Converting XML to string
Converting XML to string  Hi Friends, I had an requirement in which a java program receives an xml messages from external web application... code so that I can study from it. Thanks in advance. Regards, Lisha Ahuja
Mysql Decimal Datatype
Mysql Decimal Datatype       Mysql Decimal Datatype is used to specify the numeric values. Understand with Example The Tutorial give you an example from 'Mysql Decimal Datatype
MySQL Converting Expression
MySQL Converting Expression       MySQL Convert function is used to convert the data from one type... function and operator in mysql. The Tutorial illustrate an example from 'MySQL
Convert Decimal into Binary
takes a decimal number from console and it converts it  into binary format... Convert Decimal into Binary        In this section, you will learn to convert decimal number
Converting Strings to Numbers
Java: Converting Strings to Numbers To convert a string value to a number..."); } } return val; }//end getInt Non-decimal Integers Convert integers with some base... these will be hexadecimal (base 16) or binary (base 2) numbers. typeExample statement int
Checking the decimal whether comma used or not
Checking the decimal whether comma used or not  I need to check the given integer whther comma used or not. For example. If the user given 123456... be like 123,456.5 The comma has to be filled from the right side after 3 digits
Convert Binary to Decimal
Convert Binary to Decimal      ... number  into a decimal number. The java.lang package provides the facility to convert the integer data into the binary to decimal.  Code Description
converting one file format to another
converting one file format to another  Hi ser I need a code to export data from data grid to PDF and XL format plz help me out
Java binary to decimal
print the decimal value from the binary value.  BinarytoDecimal.java... Java binary to decimal   ... to a decimal number. In this Tutorial we want to describe you a code that help
Converting HTML to XML - Java Beginners
Converting HTML to XML  Hi, I am generating an HTML file (JSP from a Java Struts App.) I need to figure out a way to create an XML file from that HTML document. If you can refer me to some Java Code, that would
Mysql converting expression
Mysql converting expression This example illustrates how to use the cast... to convert the data from one type to another type. The CONVERT() function is used...' LIKE CONVERT(image USING binary) FROM pictures;  
Converting Collection to an Array
Converting Collection to an Array       Here is the illustration for the conversion from... by the system according to the number of elements in the list. Each and every
xml Converting to java using JDOM
xml Converting to java using JDOM  Hello , I am new to java and JDom so i make a Xml file and i need help to read it from java using objects , my idea is i have school has a class,class has a 3 students ,student has a address
java program (integer/decimal) - Java Beginners
java program (integer/decimal)  Accept a number from the user as command line arguments. The number could be an integer or decimal value. ? Display the absolute value of the input number ? Display the rounded off value
Convert Euro to dollar, need to be able to enter decimal!
Convert Euro to dollar, need to be able to enter decimal!  Hi... currency conversion from euros to dollars: it prompts the user for the conversion... a decimal for the conversion factor or quantity the program will give me an error
Convert Euro to dollar, need to be able to enter decimal!
Convert Euro to dollar, need to be able to enter decimal!  Hi... currency conversion from euros to dollars: it prompts the user for the conversion... a decimal for the conversion factor or quantity the program will give me an error
DecimalFormat
DecimalFormat       java.text.DecimalFormat is the class that is used for converting the decimal... automatically rounds off  to the number of decimal places.    Handling
Java Convert decimal to binary using Stacks
Java Convert decimal to binary using Stacks In this section, you will learn how to convert decimal into binary using stacks. You all are aware of Stacks... operation removes an item from the top of the list. Using these operations, we
Hexadecimal numbers multiplication
Hexadecimal numbers multiplication  Sir, I have to multiply 128 bit hexadecimal numbers. Do u have any logic for this?? The numbers are like ab7564fa342b5412c34d9e67ab341b58
convert to decimal
convert to decimal  f42a4 convert to decimal by using java
Java code for converting between .xls to .xlsx and vice versa - Java Beginners
Java code for converting between .xls to .xlsx and vice versa  I've a web application which allows clients to upload or download MS Excel sheets. I need a solution in Java from which i can upload in MS Excel 2003 and download
Getting and sending data to and from mobile and the system
Getting and sending data to and from mobile and the system  Hi, For getting and sending data to mobile from system.make system is a server.From mobile send a request to the server and get response.Then process the response
swing program for decimal to binary
swing program for decimal to binary  swing program for decimal to binary
Integers
, .... Integers are represented in binary inside the computer, and in decimal in Java source programs. Java automatically converts decimal numbers you write... characters. Making it integer is largely because of Java's legacy from C++. Don't
System Properties
Java: System Properties From System Properties you can find information about the operating system, the user, and the version of Java... in a file. Getting the System Properties Typically you get one property

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.