如何让我的System.out.prints排在彼此之下?

时间:2015-09-01 03:42:44

标签: java

我希望所有回复在彼此之间排列

示例:

X = Y

Y = X

等等......

x = y y = x ect ...

// Julian Vizcarra
// Lab 05 question 2
public class Lab05_02 {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
// Enter an integer
System.out.print("Enter an integer: ");
int number = input.nextInt();

//compute math
int ok = number/5;
int ok2= number/6;

//If statement
if (number % 5 == 0 && number % 6 == 0){
 System.out.print("Is " + number + " divisible by 5 and 6?" + " True "  );}  

    else {System.out.print("Is " + number + " divisible by 5 and 6?" + " False "  );  }

if (number % 5 == 0 || number % 6 == 0) {
 System.out.print("Is " + number + " divisible by 5 or 6?" + " True "  );}

    else {System.out.print("Is " + number + " divisible by 5 or 6?" + " False "  );}

if (number % 5 == 0 ^ number % 6 == 0) {
System.out.print("Is " + number + " divisible by 5 or 6, but not both" + " True");}

    else {System.out.print("Is " + number + " divisible by 5 or 6, but not both" + " False");}
}
}

我的输出是:

输入一个整数:60

60可被5和6整除吗?真的是60可被5或6整除吗? True是60可以被5或6整除,但不能同时为False

2 个答案:

答案 0 :(得分:4)

使用System.out.println()代替System.out.print()

答案 1 :(得分:0)

System.out.println()或System.out.println(“\ n”)做你想做的事