-2

I want all the responses to line up under each other

example:

x=y

y=x

ect...

not

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");}
}
}

my output is:

Enter an integer: 60

Is 60 divisible by 5 and 6? True Is 60 divisible by 5 or 6? True Is 60 divisible by 5 or 6, but not both False

thelion209
  • 21
  • 2

2 Answers2

4

Use System.out.println() instead of System.out.print().

mazhar islam
  • 5,561
  • 3
  • 20
  • 41
0

System.out.println() or System.out.println("\n") do what you want

kris ho
  • 51
  • 1
  • 9
  • Typo in the answer, your second one should probably be "print" instead of "println":System.out.println("value") or System.out.print("value\n") – LaFayette Sep 01 '15 at 04:22