วันศุกร์ที่ 19 กรกฎาคม พ.ศ. 2556

Condition (Medium)

Proposition
(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 out put should be
'IS 25 an even number? False'


Code
int x=26;

if (x%2==0) {
  println("Is"+" "+x+" an even number? True");
}
else {
  println("Is"+" "+x+"an even number? False");

}


Output
Is 26 an even number? True


Text book name : Programming and Problem solving with Java second edition
Author : Nell Dale and Chip Weems
ISBN : 978-0-7637-3402-2


ไม่มีความคิดเห็น:

แสดงความคิดเห็น