Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. public static void main(String[] args) {
  2. // Divisible by 5 and 6 or not
  3. Scanner s = new Scanner(System.in);
  4. int x;
  5. System.out.print("Enter an integer: ");
  6. x = s.nextInt();
  7. if ((x % 5==0) && (x % 6==0)){
  8. System.out.print("is "+x+" divisible by 5 and 6? ");
  9. System.out.print("true");
  10. }else{
  11. System.out.print("is "+x+" divisible by 5 and 6? ");
  12. System.out.print("false");
  13. }// Divisible by 5 or 6
  14. if ((x % 5==0) || (x % 6==0)){
  15. System.out.print("nIs "+x+" divisible by 5 or 6? ");
  16. System.out.print("true");
  17. }else{
  18. System.out.print("Is "+x+" divisible by 5 or 6? ");
  19. System.out.print("false");
  20. }// Divisible by 5 or 6,but not both
  21. if ((x % 5==0) || (x % 6==0)){ here is my problem, i cant figure out the code for "not both" part
  22. System.out.print("Is "+x+" divisible by 5 or 6, but not both? ");
  23. System.out.print("true");
  24. }else{
  25. System.out.print("Is "+x+" divisible by 5 or 6, but not both? ");
  26. System.out.print("false");
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement