Formatting a double

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • squizzel
    New Member
    • Sep 2011
    • 1

    Formatting a double

    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:

    Code:
     
    
    import java.util.*;
    public class numberthree {
    
    	public static void main(String[] args) {
    		
    		double DAY , space , mill , thou , hund; 
    		
    		Scanner keyboard = new Scanner(System.in);
    		
    		System.out.println("Please input the number of days MyMail has been running :");
    		DAY = keyboard.nextDouble();
    		
    		space =  ( (( 512 * Math.pow(2, 20) )/ 15 ) * DAY ) + (1024  * Math.pow(2, 20)) ;
    		
    		
    		System.out.println(space);
    		
    		 	mill = space / 1000000;
    		 	thou = space % 1000000;
    		 	hund = space % 1000;
    		
    		
    		System.out.printf("Email storage space (in bytes): " +  "%.2f" , mill + "million" +  thou +  "thousand" + hund);
    	
    		
    	
    	
    	
    	
    	
    	}
    
    
    
    }
    Thanks for the help!
Working...