Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
roman2decimal
- Page 1
Re: How Build video-player in html And css ?
Programming
1 Month Ago
by Kirubel_2
body{ /* background: url(../img/w11.png); */ background: url(../img/m.jpg); background-size: cover; background-repeat: no-repeat; margin: 0; padding: 0; height: 101vh; overflow-y: hidden; } .container button{ background: transparent; …
roman numeral calculator problems
Programming
Software Development
16 Years Ago
by robotnixon
First off, happy thanksgiving everybody. Second, my program has problems. I've discovered a horrible way (for me anyway) to design and my attempts to fix it aren't getting any where. I have to design a roman numeral calculator (input romans, output romans) with at least two functions (decimal->roman, roman->decimal). I started by designing …
Re: roman numeral calculator problems
Programming
Software Development
16 Years Ago
by robotnixon
My output being in the right format means it looks like this after running it: Enter a roman expression X + X = Enter a roman expression. Post #3 has the old output. I had changed all of the romanNums to roman and sum is initialized as 0 in convertToDecimal. I did what you suggested with cout statement, and my output was 50 lines, with…
Re: roman numeral calculator problems
Programming
Software Development
16 Years Ago
by robotnixon
[QUOTE=Salem;476612]# int convertToDecimal(string&) # { # char roman[20]; Try int convertToDecimal(char roman[20]) Or better yet, make roman your std::string variable. By leaving the parameter unnamed, you're passing a value, but totally ignoring it. Do you have a debugger? If so, now is the time to get used to using it.[/QUOTE]…
Re: roman numeral calculator problems
Programming
Software Development
16 Years Ago
by Lerner
It could be something like: [code] int convertToDecimal(string); int main() { string roman; cin >> roman; int num = convertToDecimal(roman); } int convertToDecimal(string roman) { int length = roman.length(); int number = 0; int counter = 0; sum = 0; for(counter = length; counter >= 0; counter --) //…
Re: roman numeral calculator problems
Programming
Software Development
16 Years Ago
by Salem
# int convertToDecimal(string&) # { # char roman[20]; Try int convertToDecimal(char roman[20]) Or better yet, make roman your std::string variable. By leaving the parameter unnamed, you're passing a value, but totally ignoring it. Do you have a debugger? If so, now is the time to get used to using it.
Re: roman numeral calculator problems
Programming
Software Development
16 Years Ago
by Lerner
Intinalize sum to zero in convertToDecimal() before you try to add something to it. You never use the values passed to convertToDecimal() in the form of roman. Instead, you ask for additional input in the form of romanNum.
Re: roman numeral calculator problems
Programming
Software Development
16 Years Ago
by robotnixon
[QUOTE] You never use the values passed to convertToDecimal() in the form of roman. Instead, you ask for additional input in the form of romanNum.[/QUOTE] I'm not sure I understand this part. I pass the value as a string to convertToDecimal and need to return an integer but can't redefine things. I used the length member function to read …
Re: roman numeral calculator problems
Programming
Software Development
16 Years Ago
by robotnixon
I changed this: [inlinecode] int convertToDecimal(string&) { char roman[20]; int length = strlen(roman); [/inlinecode] My output is in the correct format but there's no answer.
Re: roman numeral calculator problems
Programming
Software Development
16 Years Ago
by Lerner
>>My output is in the correct format but there's no answer. I'm not sure what this means. However, if all you did was change the lines you listed in post #7, then you've got some more work to do. Remove all mention to romanNum by replacing every appearance to roman in convertToDecimal(), or rename the variable passed to convertToDecimal…
Re: Roman Numerals (Python)
Programming
Software Development
14 Years Ago
by woooee
Roman to integer. Note that it will take something like XXIXV and convert it. If someone already has a routine to check for valid input, please post it. And I'm afraid we've just eliminated one standard homework question. Oh well, nothing lasts forever. [CODE]roman_to_decimal = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, \…
Decimal format in java
Programming
Software Development
12 Years Ago
by mags11
I am trying to get the program's decimal to output in two decimal places after the decimal. Please advise. [CODE] // MilesPerGallon.java // Program designed by XY import javax.swing.JOptionPane; // Needed for JOptionPane. import java.text.DecimalFormat; // Keeping proper decimal format. public class MilesPerGallon {…
Re: Decimal format in java
Programming
Software Development
12 Years Ago
by xcrypted1
[QUOTE=mags11;1761663]I am trying to get the program's decimal to output in two decimal places after the decimal. Please advise. [/QUOTE] You created dec here but you didn't use it anywhere. [CODE] DecimalFormat dec = new DecimalFormat("###.##"); [/CODE] There are several ways to do this, but, what you did is good. …
Re: Decimal Parse and CultureInfo for Decimal separator
Programming
Software Development
13 Years Ago
by ddanbe
Mine is nl-BE also with comma as decimal point. The MessageBox gives 123,45 (with comma) if I execute the OPs code. Perhaps try something like this? [CODE=c#] Decimal d = Decimal.Parse(tmp, myInfo); //123.45 string str = d.ToString(CultureInfo.GetCultureInfo("es-ES").NumberFormat);//123,45[/CODE]
Decimal Parse and CultureInfo for Decimal separator
Programming
Software Development
13 Years Ago
by charlybones
I've looked around this forum, and the rest of the internet, but my code is not working. Here is the problem: I read XML files that are in en-US culture. The decimal separator is a dot ".". Given the string "123.45", I want to convert the separator from a dot, to a comma. The current code doesn't work. [CODE] String …
Re: Decimal Parse and CultureInfo for Decimal separator
Programming
Software Development
13 Years Ago
by Momerath
Of course it doesn't work, you are parsing en-US as es-ES. You need to do the parse first, then convert cultures for output. [code]String tmep = "123.45"; Decimal value = Decimal.Parse(test, system.Globalization.CultureInfo.InvariantCulture); System.Windows.Forms.MessageBox.Show("New value: " + value);[/code] This should work,…
Re: Decimal Parse and CultureInfo for Decimal separator
Programming
Software Development
13 Years Ago
by Mitja Bonca
Try this: [CODE] string a = "12.34"; decimal b = Convert.ToDecimal(a, System.Globalization.CultureInfo.InvariantCulture); [/CODE]
decimal to hexadecimal function
Programming
Software Development
12 Years Ago
by pwolf
Stuck again, still, im learning from my large list of mistakes, haha so this time im trying to convert a decimal to hexadecimal, i tried using hex(number) but its not suitable for the situation as this returns a string. and i dont know how or if i can convert a string to hexadecimal. I tried to use string formatting as follows; ` return "%x&…
Re: Decimal Parse and CultureInfo for Decimal separator
Programming
Software Development
6 Years Ago
by DOUGLAS_9
String tmp = "123.45"; System.Globalization.CultureInfo myInfo = System.Globalization.CultureInfo.CurrentUICulture; /****The above line returns my culture, es-ES where the number separator is ","***/ System.Windows.Forms.MessageBox.Show("New value: "+ Decimal.Parse(test.Replace(".", &…
Re: decimal to hexadecimal function
Programming
Software Development
12 Years Ago
by bbixby1764
[code] # Write a function that does a decimal to hexadecimal conversion. # Hint: Make use of "%x" for hexadecimal format. def dec2hex(num): return str('0x' + '%.2x' % num)[/code] Doing python tutorial, some of the examples are badly written, hard to understand what they want. the str() might be unnecessary, .2x gives …
Re: decimal to hexadecimal function
Programming
Software Development
12 Years Ago
by pwolf
[QUOTE=bbixby1764;1747700][code] # Write a function that does a decimal to hexadecimal conversion. # Hint: Make use of "%x" for hexadecimal format. def dec2hex(num): return str('0x' + '%.2x' % num)[/code] Doing python tutorial, some of the examples are badly written, hard to understand what they want. the str() might …
decimal places in vb
Programming
Software Development
14 Years Ago
by dixie_flatline
Hi, i have a project to do in VB and its been a while i done anything in it. My problem is taxation and decimal places. How can I round 2.19 to 2.20 ? the actuall number was 2.194 and vb6 rounds it at 2.19, is this as it should behave? tnx
Re: decimal places in vb
Programming
Software Development
14 Years Ago
by AndreRet
You can either use the format function as in - [CODE]txtAnswer.Text = Format(p - (a * f - ct), "##,##0") 'Using the 0(zero) at the end will round the number off to a zero.[/CODE] Or you can use the round function as in - [CODE]Dim TotCost As Single Dim srTotal As String Dim Quarters As Integer ' This routine assumes that …
Decimal places and string formatting of Double Values
Programming
Software Development
12 Years Ago
by charlybones
Greetings. Ok so my problem is that I get a "Currency" formatted value from the database and this value sometimes comes as a whole number (without decimals) and sometimes it doesn't. But, when I output the information as "string" into an XML File, I [B][I]always need to show the 2 decimal places even if they are zero. [/…
Re: decimal & fraction
Programming
Software Development
17 Years Ago
by server_crash
Decimal form: use DecimalFormat Fraction Form: use modulus division and a little math.
Re: decimal to binary, palindrome!
Programming
Software Development
14 Years Ago
by jeniferandrews
decimal to binary conversion:=> [code] int no,d; int ctr=0; scanf("%d",&no); while(no>0) { no=no/2; d=no%2; printf("%d",d); ctr++; } [/code] to check whether it is a palindrome apply this logic:=> [code] int rev=0; int a; while(no>0) { d=d%10; no=no/10; rev=rev*10+d; a=rev; } …
Re: Roman Numerals to Arabic Numbers and Vice Versa
Programming
Software Development
13 Years Ago
by rubberman
Do we get extra credit for helping you? :-) Write down ALL of the rules to convert Roman to Decimal. Remember though L is 50 and X is 10, whether or not the 10 is added to or subtracted from the 5 depends upon what side of the L it is found. So, LX is 60 and XL is 40. Likewise for other numbers. V is 5, I is 1, VIII is 8, IV is 4, 3 is III, 2 is …
roman numeral to decimal integer
Programming
Software Development
14 Years Ago
by naveenreddy61
the code takes each character and stores where and how many times a roman numeral appears and the assess the integer. this is my first code im posting. anything to make the code better is most welcome. roman numeral refers to M=1000 D=500 C=100 L=50 X=10 V=5 I=1 and uses the standard method of assessing roman numeral.
Re: roman numeral to decimal integer
Programming
Software Development
14 Years Ago
by Salem
First, INDENT your code. [code] #include<stdio.h> main() { int n = 0, i = 0, x = 0, ax = 0, bx = 0, cx = 0, dx = 0, ex = 0, fx = 0, gx = 0, g[10], a[10], b[10], c[10], d[10], e[10], f[10]; char r[10]; printf("please enter the roman numeral :"); scanf("%s", &r); for (; i < 10; i…
Re: roman numeral to decimal integer
Programming
Software Development
14 Years Ago
by adnan.siddique
i think i have the best one that is [CODE]//code to convert roman numeral to integer #include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> int ret_level(char ch) { switch (ch) { case 'I': return 1; case 'V': return 5; case 'X': return 10; case 'L': return 50; case 'C': return 100; case …
1
2
3
17
Next
Last
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Forums
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC