subject

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.

Supply a Battery class that tests all methods. Make sure to print the remaining capacity.

If we create an instance of Battery class with 2000 mAh, call drain (500) and then call getRemainingCapacity(), it should print 1500mAh; now if we call charge() and then call getRemainingCapacity() it should print 2000mAh

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:30
How do you make a lenny face? plz, brailiest to who can answer first.
Answers: 1
question
Computers and Technology, 23.06.2019 09:10
Effective character encoding requires standardized code. compatible browsers. common languages. identical operating systems.
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Font size, font style, and are all aspects of character formatting.
Answers: 2
You know the right answer?
Write a class Battery that models a rechargeable battery. A battery has a constructor

pu...
Questions
question
Mathematics, 25.09.2021 17:30
question
Mathematics, 25.09.2021 17:30
question
Mathematics, 25.09.2021 17:30
question
Mathematics, 25.09.2021 17:30
Questions on the website: 13722363