converting From Hexadecimal to Decimal System

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
View Answers

July 12, 2010 at 2:33 PM


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. (adsbygoogle = window.adsbygoogle || []).push({}); Thanks
Convert Hexadecimal to Decimal
Convert Hexadecimal to Decimal     ... a hexadecimal number into decimal. Code Description:ADS_TO_REPLACE_1 This program takes a hexadecimal number at console and converts it into a decimal number using
Convert Decimal to Hexadecimal
Convert Decimal to Hexadecimal     ... into hexadecimal. The java.lang package provides the functionality to convert a decimal... a decimal value and  converts it  into  a hexadecimal (Base 16
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:ADS_TO_REPLACE_1
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
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
ModuleNotFoundError: No module named 'hexadecimal'
ModuleNotFoundError: No module named 'hexadecimal'  Hi, My Python... 'hexadecimal' How to remove the ModuleNotFoundError: No module named 'hexadecimal' error? Thanks   Hi, In your python environment
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
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
illustrate an example from 'SQL Decimal'. To understand and grasp the example... SQL Decimal       SQL Decimal is used to specify the values in decimal datatype. The Decimal datatype
convert to decimal
convert to decimal  f42a4 convert to decimal by using java
Convert Hexadecimal into Binary and Long
Description:ADS_TO_REPLACE_1 This program helps you in converting the hexadecimal... Convert Hexadecimal into Binary and Long   ... the hexadecimal data into the binary and long format. The java.lang package provides
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... at the console (using the keyboard) and converts the hexadecimal data
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
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
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 ISO8601-compliant String to java.util.Date
Converting ISO8601-compliant String to java.util.Date  Converting ISO8601-compliant String to java.util.Date
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
System
System  What is System in System.out.println() method? Is it a Class or a Package
How to convert binary to decimal in Java?
and then converting it to a decimal number. The java.lang package provides... How to convert binary to decimal in Java program? In this section we are going to convert a binary number to it decimal representation
Convert Decimal to Integer
This program helps you in converting a decimal type data into an integer. The parseInt... Convert Decimal to Integer       In this section, you will learn to convert  a decimal number
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
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
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
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.ADS_TO_REPLACE_1
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
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
Mysql Decimal Datatype
Mysql Decimal Datatype       Mysql Decimal Datatype is used to specify the numeric values. Understand with ExampleADS_TO_REPLACE_1 The Tutorial give you an example from 'Mysql
executing a batch file which depends on jar files from a system tray but console should not display.
executing a batch file which depends on jar files from a system tray... and some output generated by System.out.println()'s from system tray. I want to see the frame outside of system tray and i want to see the console with output
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 and converting a PDF to XML
Java and converting a PDF to XML  I reviewed your example - https://www.roseindia.net/tutorial/java/xml/pdftoXML.html - and on many users group... getting a response from them.Can you help me out ?? This project is very important
Java and converting a PDF to XML
Java and converting a PDF to XML  I reviewed your example - https://www.roseindia.net/tutorial/java/xml/pdftoXML.html - and on many users group... getting a response from them.Can you help me out ?? This project is very important
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
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
Convert Binary to Decimal
decimal long. This method has been used for converting a long to a string... Convert Binary to Decimal      ... number  into a decimal number. The java.lang package provides the facility
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 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
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
Convert Decimal into Binary
This program takes a decimal number from console and it converts it ... 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
ModuleNotFoundError: No module named 'pycopy-decimal'
ModuleNotFoundError: No module named 'pycopy-decimal'  Hi, My... named 'pycopy-decimal' How to remove the ModuleNotFoundError: No module named 'pycopy-decimal' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'decimal-monkeypatch'
ModuleNotFoundError: No module named 'decimal-monkeypatch'  Hi, My... named 'decimal-monkeypatch' How to remove the ModuleNotFoundError: No module named 'decimal-monkeypatch' error? Thanks   Hi

Ads