31 Solved Topics

Remove Filter
Member Avatar for
Member Avatar for 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, …

Member Avatar for DOUGLAS_9
0
18K
Member Avatar for sundog1

Hi Guys, If you have a Text Box which you are putting in the Decimal Places such as "15.50". Then Submitting this to a Access Database then on re-fresh the data shows in the grid view as "15.5". Where abouts should this be modified so that it shows Decimal Places? …

Member Avatar for sundog1
0
3K
Member Avatar for adil.ghori

Hello ! I have a script, that i m running on visual C++ compiler everything is alright with it, working properly but in the result, I can see on one digit after decimal, not 2, i wanna display two digit i.e 31.02 ; Code is; # include <iostream.h> # include …

Member Avatar for adil.ghori
0
379
Member Avatar for UNDER-18 FG

Hi, I was assigned by my teacher to create a simple calculation program about movie tickets that are sold in a local movie theater. So, I created the coding, and it turned out perfect. Here it is: import java.util.Scanner; public class MovieTheater { public static void main(String[] args) { String …

Member Avatar for UNDER-18 FG
0
315
Member Avatar for magicmarkuk

Hi I have a script which displays a price but currently is not fixed to 2 decimal places so a price such as $2.50 shows as $2.5 which to me looks wrong. The line of code is `amount += parseFloat($(this).metadata().amount);` Looking around I see there is a function `toFixed()` but …

Member Avatar for Troy III
0
213
Member Avatar for TarkiB

Hi there, I'm having trouble with floats in Java. My program accepts a number in the form of a float. The number typically has two decimals (but not always). It seems to work fine in most cases. For example, I could put in 54.67, and that number would be passed …

Member Avatar for JamesCherrill
0
405
Member Avatar for abhishek_ag

Hi Guys, I have written the below program to convert binary to octal, it is giving me erroneous results. On entering 1111 as the input number I should get 17 as the output, whereas I am getting 16707000337 as the output. Kindly help me out, below is my program: /*program …

Member Avatar for abhishek_ag
0
262
Member Avatar for 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 { public static void main(String args[]) { …

Member Avatar for mags11
0
2K
Member Avatar for stamatt45

I'm writing a program to convert Decimal numbers to binary, hexadecimal, and BCD as a refresher before i start getting code assignments in school. I'm almost done, but i have a seg_fault (compiler says decToHex function) in 1 function and i am hoping for some feedback on the others. I'll …

Member Avatar for raptr_dflo
0
3K
Member Avatar for Curtisq

So my problem is writing a program that asks the user to input a number wich is stored with scanf then print the binary representation of that number in 32 bits, as in if the number is 1 i would need 31 0's and a 1. [CODE]#include <stdio.h> void dec_bin(long …

0
102
Member Avatar for calebcook

Hi. I need a function which will convert a decimal to a fraction, so that I can put in [CODE]echo dec2frac(1.75);[/CODE] and it'll output 1 3/4. Any suggestions? Thanks

Member Avatar for diafol
0
3K
Member Avatar for 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 …

Member Avatar for charlybones
0
213
Member Avatar for Simplified

Hello all I'm having a few issues with a Python program in that I am performing decimal calculations on and most values come up as desired, however every so often, when there is a very small decimal, the number is represented like "6.80E-7" rather than the desired "0.000000680". Here's a …

Member Avatar for Simplified
0
209
Member Avatar for rookanga

Im trying to make a fast food program on which the user will input the amount that he has, then he will click on what he wants, by using check boxes. There are 7 different check boxes with 7 different amounts of money. I got an idea on what to …

Member Avatar for rookanga
0
948
Member Avatar for november_pooh
Member Avatar for Bilal gulbaz
2
3K
Member Avatar for 24x24

I am to write a program that converts either binary, hex or octal to decimal. We are to use methods for the first time (Not a problem). I have written almost all of the code but the conversion. We can't use int.toDecimal or any shortcut. All must be long coded …

Member Avatar for 24x24
0
230
Member Avatar for commando1200

Im trying to make a tax and tip calculator and whenever the tax comes up it goes 10 or more decimal places and im trying to restrict it to two. [code=java] public static void main(String[] args) { double cost, total, tip, taxtotal, tiptotal, subtotal, grandtotal; Scanner myScanner = new Scanner(System.in); …

Member Avatar for commando1200
0
193
Member Avatar for Rickay

[CODE]int main() { static short multiplycounter; static short dividecounter; double decimal; int rdecimal; cin >> decimal; rdecimal = int(decimal); cout << setprecision(10) << decimal << endl << rdecimal << endl; if(rdecimal % 1 != 0) { while(rdecimal % 1 != 0) { if(rdecimal % 1 == 0) { break; } …

Member Avatar for Rickay
0
622
Member Avatar for hiddepolen

Hi Daniweb! I couldnt find my problem anywhere else on this forum, so I decided to make my own thread... My problem: I'm trying to make a function to decide how many decimals a 'double' has. My code (slightly edited, here's the base of it): [CODE] // int m = …

Member Avatar for MattyRobot
0
183
Member Avatar for Sunshineserene

Hi, I am getting this error for my codes: Exception in thread "main" java.lang.NumberFormatException: For input string: "{ 1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0}," at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224) …

Member Avatar for Sunshineserene
0
2K
Member Avatar for Sunshineserene

Hi, I want to know to rows and columns of numbers from a text file. I do not want to read it as a string, but one number (including numbers with decimal) by itself. I tried using FileInputStream and DataInputStream, but I'm not really good at it. I don't know …

Member Avatar for tong1
0
2K
Member Avatar for Sunshineserene
Member Avatar for Alochai

[CODE]/* Name: Copyright: Author: Date: 14/09/10 21:17 Description: */ #include<iostream> #include<istream> #include<ostream> #include<string> int c_f_fraction(); int c_f_decimal(); int c_f_percent(); int convert_to(); int convert(); int help(); std::string convert_code(""); float c_f_fraction_1(0); float c_f_fraction_2(0); float c_f_result(0); float c_f_decimal_1(0); float c_f_percent_1(0); int help_code(0); int main() { std::cout << "\nWhich would you like to convert, …

Member Avatar for Alochai
0
1K
Member Avatar for guru_iyer

I've been trying to display the equivalent decimal number of the input binary number. I tried the below piece of code but am not achieving the result. I don't seem to understand why? Please Help!! [CODE] #include<stdio.h> #include<conio.h> #include<math.h> int a=0; int main() { char bin[8]; int i=0,len=0,r=0,w; printf("Enter a …

Member Avatar for volvo877
0
507
Member Avatar for muralibobby2015

hello.. i have to do substraction of two php variables which is having datatype varchar. i am trying like this.[CODE] $a=5; $b=3; $c=$a-$b; [/CODE] but for float values [CODE] $a=3000.90; $b=2000; $c=$a-$b; [/CODE] out put is $1000.9. ok even i echo $a i am getting 3000.9 how to get two …

Member Avatar for muralibobby2015
0
85
Member Avatar for PomonaGrange

Hi All, I am trying to program a web based cash register/POS application. I would like to use a function to format the number in the "Amount Received" text box. The idea I have in mind is to always keep two decimal places at all times. For Example: if someone …

Member Avatar for fxm
0
3K
Member Avatar for j23

i want to use input validation so that the user can only input decimal numbers. can someone help [CODE] while int_x != : #this is where im having the problem print "the number entered must be a decimal number" int_x = input("Enter a decimal number:") [/CODE]

Member Avatar for ultimatebuster
0
2K
Member Avatar for 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 …

Member Avatar for dixie_flatline
0
2K
Member Avatar for apo

how can a make the floating variable show just 4 digits i mean : 8.6540098 to just 8.654 i guess what i'm trying to say is "less decimals" :D

Member Avatar for jonsca
0
127
Member Avatar for rtllz

Im using xcode to write my program. Every time I build and run the program it will do everything fine, until the end. It keeps giving me an answer of 0 no matter what i put. Need help to figure out what im doing wrong thanks in advance. [CODE]//price_converter #include …

Member Avatar for rtllz
0
142

The End.