New Line
How to start a new line? Is my coding correct so far? Please let me know.
Voters
IntellectualGuy (336)
Easy just put \n
class Main {
public static void main(String[] args) {
System.out.print("Enter the monthly subscription fee:\n");
System.out.print("9.99");
System.out.print("Enter the number of paying customers:\n");
System.out.print("26000000");
System.out.print("This company makes $259740000 per month");
System.out.print("This company makes $3116880000 per year");
}
}
or you could write System.out.println
instead of System.out.print
, both of those should work
Btw I suggest using proper indentation in java, it can make your code way easier to read
EpicGamer007 (1485)
to print a new line, put \n
in the string
ObiVibKenobi (169)
Hi there! I don’t know much java, but I do know that to print a new line, you could replace print
with printf
and put in %n
where new lines should be. So, you could replace your code with this:
class Main {
public static void main(String[] args) {
System.out.printf("Enter the monthly subscription fee:");
System.out.printf("%n9.99");
System.out.printf("%nEnter the number of paying customers:");
System.out.printf("%n26000000");
System.out.printf("%nThis company makes $259740000 per month");
System.out.printf("%nThis company makes $3116880000 per year");
}
}
Solution
to put a new line in java, use
\n
.like that. You can add more.
It should work