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, 24.06.2019 05:30
Why is hard disk space important to an audio engineer? why are usb ports and firewire ports useful for an audio engineer? explain in 2-3 sentences. (3.0 points) here's a list of different audio software: ableton live apple inc.'s garageband apple inc.'s logic studio digidesign's pro tools propellerhead sofware's reason sony creative software's acid pro steinberg cubase steinberg nuendo choose one of the software programs listed above, and then go to that software program's web site. read about what the software program is used for, and then write 4-5 sentences about what you learned. (10.0 points) which type of software license is the most limiting? why? explain in 2-3 sentences. (3.0 points) when sending a midi channel voice message, how can you control the volume of the sound? explain in 2-3 sentences. (4.0 points)
Answers: 1
question
Computers and Technology, 24.06.2019 10:10
Which view in a presentation program displays a split window showing the slide in the upper half and a blank space in the lower half?
Answers: 1
question
Computers and Technology, 24.06.2019 10:20
Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should not be added to the list). these values entered by the user are added to a list we call 'initial_list'. then write a function that takes this initial_list as input and returns another list with 3 copies of every value in the initial_list. finally, inside print out all of the values in the new list. for example: input: enter value to be added to list: a enter value to be added to list: b enter value to be added to list: c enter value to be added to list: exit output: a b c a b c a b c note how 'exit' is not added to the list. also, your program needs to be able to handle any variation of 'exit' such as 'exit', 'exit' etc. and treat them all as 'exit'.
Answers: 2
question
Computers and Technology, 24.06.2019 19:50
How to unblock on chrome book? ?
Answers: 1
You know the right answer?
Write a class Battery that models a rechargeable battery. A battery has a constructor

pu...
Questions
question
Health, 06.02.2021 06:40
question
Mathematics, 06.02.2021 06:40
question
Mathematics, 06.02.2021 06:40
question
English, 06.02.2021 06:40
Questions on the website: 13722362