Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printf not skipping lines

Status
Not open for further replies.

ilovelinux2006

Programmer
Jun 6, 2006
32
US
Hello everyone,

I created a simple program, and i noticed that printf is not skipping any lines. How do I have printf skip lines?? Below is the program:

import java.util.Scanner;

public class Testin {
public static void main(String[] args) {
double number = 5;
Scanner input = new Scanner(System.in);
System.out.print("Enter a number: ");
double special = input.nextDouble();
System.out.printf("This is the number with 3 decimals: %.3f", special);
System.out.printf(" This is the same number times 5: %.3f", special*number);

}
}


And here is the output:

Enter a number: 65
This is the number with 3 decimals: 65.000 This is the same number times 5: 325.000

(with println or print there would be 3 different lines, not 2) Please help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top