Java #53: How to Print only up to Two Decimal Spaces with printf in Java

*Watch copying and pasting the quotation marks, you may have to retype them to avoid an error
—————————-Output—————————–


——————–Beginning of Source Code——————————-

//Programmer: Akinwale Owi
//Company: Dagba Computers
//Program Purpose: Print only up to two decimal places in java using printf
package javaapplication39;

public class JavaApplication39 {

public static void main(String[] args) {

//Double we will format
double money = 1234.45433;

//Printing out Double before formatting
System.out.printf(“Printing money = ” + money + “\n”);

//Printing out double after Formatting
System.out.printf(“New money = %1.2f” + “\n”, money);

} //End of main
}//End of Public

//End of Program

———————End of Source Code———————————-

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: