473,569 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Formatting a double

1 New Member
Ok so I have this number 1.4316557653333 333E9 and I need to format this number so I can print out 1431 million 655 thousand and 765

Here is my curent code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. import java.util.*;
  4. public class numberthree {
  5.  
  6.     public static void main(String[] args) {
  7.  
  8.         double DAY , space , mill , thou , hund; 
  9.  
  10.         Scanner keyboard = new Scanner(System.in);
  11.  
  12.         System.out.println("Please input the number of days MyMail has been running :");
  13.         DAY = keyboard.nextDouble();
  14.  
  15.         space =  ( (( 512 * Math.pow(2, 20) )/ 15 ) * DAY ) + (1024  * Math.pow(2, 20)) ;
  16.  
  17.  
  18.         System.out.println(space);
  19.  
  20.              mill = space / 1000000;
  21.              thou = space % 1000000;
  22.              hund = space % 1000;
  23.  
  24.  
  25.         System.out.printf("Email storage space (in bytes): " +  "%.2f" , mill + "million" +  thou +  "thousand" + hund);
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.     }
  34.  
  35.  
  36.  
  37. }
  38.  
Thanks for the help!
Sep 22 '11 #1
0 1606

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1328
by: bojanraic | last post by:
Hi! I am about to submit an article on a PHP-based site (BBCode is used for formatting), and I have a formatting problem: I am not sure how to print double quotes (" "). I tried some character escaping, but it didn't work. When I did it, it only displayed a couple of backslashes more... So, how do I print something in double quotes?...
3
1286
by: Keith | last post by:
Ok, so here is the code I have so far........my question is whether it is possible to hold onto the amount of hours for each car entered without erasing it through the next entry. I need a table format like this to appear at the end with a total for all three cars. How do I handle this? Table: Car Hrs Rate > 1 ...
2
1668
by: Homer Simpson | last post by:
Hi, I'm looking for a way to format the output of my double value. For example, the result of a calculation may be 12.3456789 but I want to display 12.346 (three decimal places of precision). How do I do this? Thanks, Scott
2
2872
by: Carlos | last post by:
Hi all, just wanted to know how can I just quickly round to nearest 100th, and use the first two decimal places of a double value in a textbox, instead of all the decimals. Thanks in advance, Carlos
10
3143
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim ld_tot_pet_clean_fee_calc As Double ld_tot_pet_clean_fee_calc = li_net_total_calc * 0.0075 ld_tot_pet_clean_fee = lo_misc_func.FormatMC(ld_tot_pet_clean_fee_calc,...
1
4310
by: bsmith1111 | last post by:
I have a program that outputs the following to the screen (through visual c++) 9999999999, which is stored in a double. I would like to keep the number the way it is, but every time I output it (after converting it to a cstring), it becomes 1e+010. I've tried many different formatting ways, including stringstream formatting, sprintf(buffer,...
14
4279
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my unformatted data values (as decimals) just fine, so I know there's not a problem with the data retrieval, just the formatting. I have read that this...
11
3691
by: Ole Nielsby | last post by:
First, sorry if this is off-topic, not strictly being a C++ issue. I could not find a ng on numerics or serialization and I figure this ng is the closest I can get. Now the question: I want to serialize doubles in human-readable decimal form and be sure I get the exact same binary values when I read them back. (Right now, I don't care...
2
1330
by: Derek Hart | last post by:
I have a double stored in a DataTable: dt.Rows(i)(MergeFieldName) I want to format this and store it into a string. I have formatting stored in a database, such as "$#,##0.00"
13
1523
by: cj2 | last post by:
pages = 1 pages.tostring gives me "1" pages+1.tostring gives me "2.0" Why did it add the ".0" on there? I was looking for "2" and this screws me up. Actually this is what I was doing. In the end what I want is to print a two digit number with leading 0s.
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.