Given the following class and the failing test log, identify…
Given the following class and the failing test log, identify the root cause and propose a minimal fix. public class SimpleCounter { private int count = 0; public void increment(int delta) { if (delta > 0) { count = count + delta; } } public int getCount() { return count; } } Test snippet (JUnit-style): @Test public void testIncrementTwice() { SimpleCounter c = new SimpleCounter(); c.increment(1); c.increment(0); assertEquals(1, c.getCount()); } Run output shows the test fails with expected but was . Part A (3 pts): What is the most likely cause of this failure? (one short paragraph) Part B (3 pts): Give the minimal code change to fix the bug (show code snippet). Part C (2 pts): Give one additional short unit test (input + expected) that verifies the fix.
Read DetailsBelow is a function meant to compute a discount percentage f…
Below is a function meant to compute a discount percentage for an order quantity. The specification is: – quantity must be ≥ 1; otherwise throw IllegalArgumentException – 1..5 => 0% – 6..10 => 10% – 11+ => 20% Here is a buggy implementation: public int calculateDiscount(int quantity) { if (quantity >= 5) { return 10; } else if (quantity >= 10) { return 20; } else { return 0; } } Part A (2 pts): Identify the defect(s) in the implementation (briefly). Part B (2 pts): Give ONE concrete test case (input and expected result or exception) that would fail with this implementation and explain in one sentence why it fails. Part C (2 pts): Propose the minimal code change that fixes the defect (show only the corrected lines / small snippet). Part D (2 pts): Explain in one sentence why your fix is correct (mention ordering or boundary logic).
Read DetailsThe nurse provides information about hepatitis to a high sch…
The nurse provides information about hepatitis to a high school health occupations class. The students all volunteer examples of how hepatitis is transmitted. Which statement by one of the students indicates the need for further teaching about hepatitis transmission?
Read Details