嘿伙计们从Java开始,但我被困在这里。有人知道如何添加额外的行,这样结果就不会粘贴在彼此之后吗?
package h2.opdracht.pkg4.vraag;
import java.util.Scanner;
public class H2Opdracht4Vraag {
public static void main(String[] args) {
int a, b, c, d, e, f;
System.out.println("Enter three numbers: ");
Scanner in = new Scanner(System.in);
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
d = a + b + c;
System.out.print("Sum of the numbers = " + d);
e = d/3;
System.out.print("The average of the numbers = " + e);
f = a * b * c;
System.out.print("The product of the numbers = " + f);
if (a <= b)
System.out.print("A is the smallest number ");
else if (b <= c)
System.out.print("B is the smallest number ");
else
System.out.print("C is the smallest number ");
}
}
答案 0 :(得分:2)
使用System.out.println("Your text here");
代替打印。这增加了换行符。
答案 1 :(得分:0)
使用System.out.println
代替System.out.print
答案 2 :(得分:0)
而不是System.out.print("data");
使用System.out.println("data");
。
"print();"
之后不会添加新行,这就是为什么在println();
添加新行时,您会得到结果的原因。
有关详细信息: