码迷,mamicode.com
首页 > 其他好文 > 详细

HW3.26

时间:2016-08-13 09:56:01      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

 1 import java.util.Scanner;
 2 
 3 public class Solution
 4 {
 5     public static void main(String[] args)
 6     {
 7         Scanner input = new Scanner(System.in);
 8 
 9         System.out.print("Enter an integer: ");
10         int number = input.nextInt();
11 
12         input.close();
13 
14         System.out.print("Is " + number + " divisible by 5 and 6? ");
15         if(number % 5 == 0 && number % 6 == 0)
16             System.out.println("true");
17         else
18             System.out.println("false");
19 
20         System.out.print("Is " + number + " divisible by 5 or 6? ");
21         if(number % 5 == 0 || number % 6 == 0)
22             System.out.println("true");
23         else
24             System.out.println("false");
25 
26         System.out.print("Is " + number + " divisible by 5 or 6, but not both? ");
27         if(number % 5 == 0 ^ number % 6 == 0)
28             System.out.println("true");
29         else
30             System.out.println("false");
31     }
32 }

 

HW3.26

标签:

原文地址:http://www.cnblogs.com/wood-python/p/5767287.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!