Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started