Question: Pls complete all excises as one code. Lab 2 - Conditionals and Logic Exercise 1 Create a file named A2.java. Place all your code in
Pls complete all excises as one code.
Lab 2 - Conditionals and Logic Exercise 1 Create a file named A2.java. Place all your code in this file. Create a method with the following header: public static boolean answerCell(boolean isMorning, boolean isMom, boolean isAsleep) Define it as follows: Your cell phone rings. Return true if you should answer it. Normally you answer, except in the morning you only answer if it is your mom calling. In all cases, if you are asleep, you do not answer. answerCell(false, false, false) true answerCell(false, false, true) false answerCell(true, false, false) false Exercise 2 Create a method with the following header: public static int loneSum(int a, int b, int c) Define it as follows: 1 Given 3 int values, a b c, return their sum. However, if one of the values is the same as another of the values, it does not count towards the sum. loneSum(1, 2, 3) 6 loneSum(3, 2, 3) - 2 loneSum(3,3,3) 0 Exercise 3 Create a method with the following header: public static int blackjack(int a, int b) Define it as follows: Given 2 int values greater than 0, return whichever value is nearest to 21 without going over. Return 0 if they both go over. blackjack(19, 21) 21 blackjack(21, 19) 21 blackjack(19, 22) 19
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
