The variable "num" holds an integer user input
Write a conditional statement starting on line 9 that does the following:
-
If num is even (divisible by 2), print "__ is even"
-
If num is odd, print "__ is odd"
Examples:
In: 23 23 is odd |
1
2
3
4
5
6
7
8
9
10
11
12
|
class Main {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
System.out.print("In:");
int num = inp.nextInt();
//DO NOT CHANGE ABOVE CODE! Write your code below
String temp= num%2==0?" is even":" is odd";
System.out.println(num+temp);
}
}
|
반응형
'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
018 - Conditional Statement Practice 4 (0) | 2019.11.28 |
---|---|
017 - Conditional Statement Practice 3 (0) | 2019.11.28 |
015 - Conditional Statement Practice 1 (0) | 2019.11.26 |
011 - String Methods Practice 2 (0) | 2019.11.26 |
010 - String Methods Practice 1 (0) | 2019.11.26 |