Problem Description: Write a class Battery that models a rechargeable battery. A battery has a constructor public Battery (double capacity) where capacity is a value measured in milliampere hours. A...

JavaProblem Description:<br>Write a class Battery that models a rechargeable battery. A battery has a constructor<br>public Battery (double capacity)<br>where capacity is a value measured in milliampere hours. A typical AA battery has a capacity of<br>2000 to 3000 mAh. The method<br>public void drain (double amount)<br>drains the capacity of the battery by the given amount. The method<br>public void charge ()<br>charges the battery to its original capacity.<br>The method<br>public double getRemainingCapacity()<br>gets the remaining capacity of the battery.<br>

Extracted text: Problem Description: Write a class Battery that models a rechargeable battery. A battery has a constructor public Battery (double capacity) where capacity is a value measured in milliampere hours. A typical AA battery has a capacity of 2000 to 3000 mAh. The method public void drain (double amount) drains the capacity of the battery by the given amount. The method public void charge () charges the battery to its original capacity. The method public double getRemainingCapacity() gets the remaining capacity of the battery.
7:18<br>1Outlook<br>Done<br>BatteryTester<br>/**<br>Tester for Battery class.<br>*/<br>public class BatteryTester<br>{<br>public static void main(String[] args)<br>{<br>Battery battery = new Battery(100.0);<br>System.out.printIn(battery.getRemainingCapacity ());<br>System.out.printIn(

Extracted text: 7:18 1Outlook Done BatteryTester /** Tester for Battery class. */ public class BatteryTester { public static void main(String[] args) { Battery battery = new Battery(100.0); System.out.printIn(battery.getRemainingCapacity ()); System.out.printIn("Expected: 100.0"); battery.drain(23.4); battery.drain(9.7); System.out.printIn(battery.getRemainingCapacity()); System.out.printIn("Expected: 66.9"); battery.charge(0; System.out.printIn(battery.getRemainingCapacity()); System.out.printIn("Expected: 100.0"); } }

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here