-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab1_Question6.java
More file actions
56 lines (34 loc) · 1.14 KB
/
Lab1_Question6.java
File metadata and controls
56 lines (34 loc) · 1.14 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package day14_methodsPart2;
public class Lab1_Question6 {
public static void main(String[] args) {
// olcay // Jun 15, 2020
/*Question-6
When chipmonks get together for a party, they like to have cigars.
A chipmonk party is successfull when the number of cigars is between 40 and 60. Unless it is the weekend,
in which case there is no upper bound on the number of cigars.
Write a method that accepts number of cigars and a boolean for weekend, and prints true if the party with the given values is successful,
or false otherwise.
cigarParty(30, false) → false
cigarParty(50, false) → true
cigarParty(70, true) → true
*/
cigarParty(30, false);
cigarParty(50, false);
cigarParty(70, true);
}
public static void cigarParty(int numberOfCigars, boolean isWeekend) {
if(!isWeekend) {
if(numberOfCigars>40 && numberOfCigars<60) {
System.out.println(true);
}else {
System.out.println(false);
}
}else {
if(numberOfCigars>40) {
System.out.println(true);
}else {
System.out.println(false);
}
}
}
}