Question

Can you tell me is there other ways to put a new line between System.out.printf - standard output functions I hope it is relevant to ask

  package formattedoutput;

  public class FormattedOutput {

    public static void main(String[] args) {

        double  amount;
        amount = 43.676;
        int spaces;
        spaces = 77;


        System.out.printf( "%1.2f", amount );// the "2" in 1.2 specifies the number of digits to use after the decimal point. 
        System.out.println();
        System.out.printf("%12d", spaces ); // specifies the minimum number of spaces that should be used for the output. If the integer that is being output takes up fewer than 12 spaces, extra blank spaces are added in front of the integer to bring the total up to 12.
    }

  }
Was it helpful?

Solution

You probably just want to add %n to the end of your format string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top