Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


atoa
converting From Hexadecimal to Decimal System
2 Answer(s)      4 years and 2 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

Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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
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
losing precision converting from java BigDecimal to double
losing precision converting from java BigDecimal to double  losing precision converting from java BigDecimal to double
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
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
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
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 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
convert to decimal
convert to decimal  f42a4 convert to decimal by using java
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
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
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
Decimal Format Issue Java
Decimal Format Issue Java  Decimal Format Issue Java
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
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
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
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
Round the Decimal values
Round the Decimal values  How to round the decimal value with out using Math.round() Example:round the 2.7 as a 3.0 round the 2.4 as a 2.0
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 ISO8601-compliant String to java.util.Date
Converting ISO8601-compliant String to java.util.Date  Converting ISO8601-compliant String to java.util.Date
BINARY TO DECIMAL - Java Beginners
TO DECIMAL  Hi friend, Program to convert Binary To Decimal : import... = sc.next (); int bttm = 1; int decimal = 0; for (int i = str.length() -1; i >= 0; i--) { decimal = decimal + (bttm*Integer.parseInt
System
System  What is System in System.out.println() method? Is it a Class or a Package
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
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
How to convert long to hexadecimal - Java Beginners
How to convert long to hexadecimal  Dear all, anyone know how to convert long data to hexadecimal, please send me the information. Thanks  Hi friend, Returns the hexadecimal string it consists of a long value
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
converting string to double in java
converting string to double in java  Please post an example to converting string to double in java. Thanks!   Convert String to Double Tutorial
Conversion of Decimal to Binary in Java
Conversion of Decimal to Binary  in Java In this section we will discuss about conversion of Decimal to Binary in Java. You know that number having base 10 is a decimal number, for example 10 is a decimal number which can
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
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
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
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
java program to convert decimal in words
java program to convert decimal in words  write a java program to convert a decimal no. in words.Ex: give input as 12 output must be twelve
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
Converting PDF in to XML
Converting PDF in to XML  I have to convert PDF into XMl without any loss in text. Please suggest sth good
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
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
Java display file content in hexadecimal format
Java display file content in hexadecimal format In this section, you will learn how to read the file content and display it in hexadecimal format. Reading... in hexadecimal format. For this we have used FileInputStream class to open a file
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
Windows 8, the New Operating System from Microsoft
, the wait for the Windows 8, the new operating system from Microsoft... of simplicity in computing. Windows 8, the new operating system from Microsoft is all..., the new operating system from Microsoft is the answer to that. Let us now
Converting string to Int - JDBC
Converting string to Int  String nrate=request.getParameter("t3"); i want convert this nrate to integer to make calculations on it... so what should i do??? where t3 is a text area name and i am fetching...  Hi
Convert Decimal to Octal
Convert Decimal to Octal       In this section, you will learn to convert decimal number into octal.  The decimal format has 10 digits (that are 0,1,2,3,4,5,6,7,8,9
How to round a number to n decimal places in Java
How to round a number to n decimal places in Java  How to round a number to n decimal places in Java
 

 

 

DMCA.com