-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayingCat.java
More file actions
38 lines (23 loc) · 1.55 KB
/
PlayingCat.java
File metadata and controls
38 lines (23 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*********************************************************************************************************************
Playing Cat
===========
The cats spend most of the day playing. In particular, they play if the temperature is between 25 and 35 (inclusive). Unless it is summer, then the upper limit is 45 (inclusive) instead of 35.
Write a method isCatPlaying that has 2 parameters. Method needs to return true if the cat is playing, otherwise return false
1st parameter should be of type boolean and be named summer it represents if it is summer.
2nd parameter represents the temperature and is of type int with the name temperature.
EXAMPLES OF INPUT/OUTPUT:
isCatPlaying(true, 10); should return false since temperature is not in range 25 - 45
isCatPlaying(false, 36); should return false since temperature is not in range 25 - 35 (summer parameter is false)
isCatPlaying(false, 35); should return true since temperature is in range 25 - 35
NOTES
The isCatPlaying method needs to be defined as public static like we have been doing so far in the course.
Do not add the main method to the solution code.
**********************************************************************************************************************/
public class PlayingCat {
public static boolean isCatPlaying(boolean summer,int temperature){
if (summer==true)
return ((temperature<=45 && temperature>=25)? true:false);
else
return ((temperature<=35 && temperature>=25)? true: false);
}
}