我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!
天气: 晴朗
心情: 高兴
/*P2Q2
* Name:Wang Chaoran
* Description:(Checking whether a number is even)
Write a program that reads an integer and checks whether it is even.
For example, if your input is 25, the output should be:
Is 25 an even number? false
If your input is 2000, the output should be:
Is 2000 an even number? true
*/
import java.util.Scanner;
class P2Q2
{
public static void main(String[] args)
{
//Step One:Create a scanner
Scanner scan = new Scanner(System.in);
//Step Two:Read in an integer
System.out.println("Please input an integer");
int integer = scan.nextInt();
//Step Three:Compute and output the result
if (integer %2 ==0)
{
System.out.println("Is "+integer+" an even number? true");
}
else
{
System.out.println("Is "+integer+" an even number? false");
}
}
}
导入论坛查看(23)回复(0)引用(0)好评(0) 差评(0)
加入收藏
编辑
审核
TAG:
computing