Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write your own code, do not copy from google. Please use the code given and finish the question. I need the code in java

image text in transcribed

Please write your own code, do not copy from google. Please use the code given and finish the question.

I need the code in java with the desired output. Please include some @param comments too.

public class BatteryTester {

public static void main(String[] args) { System.out.println("Programmer: Joe Doe"); System.out.println("Date:2/19/2020 "); System.out.println("");

Battery battery_AA = new Battery(2000); // assume it is 2000 mAh AA battery

System.out.printf("4. The remaining battery_AA capacity after object instantiation is %.2f", battery_AA.getRemainingCapacity()); battery_AA.drain(50); System.out.printf(" 5. The remaining battery_AA capacity after draining 50 mAh is %.2f", battery_AA.getRemainingCapacity()); battery_AA.charge(); System.out.printf(" 6. The remaining battery_AA capacity after charging is %.2f", battery_AA.getRemainingCapacity()); }

}

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. A. Read and do the problem on p8.4, page 429. Use the provided BatteryTester class to test your Battery class. You may want to some output errors in BatterTester.java. The desired output is: 1 Project1: p8.4 page 429. 2 Programmer: John Doe. 3 Date: Tue Feb 11 16:44:08 EST 2020 4. The remaining battery AA capacity after object instantiation is 2000.00 5. The remaining battery AA capacity after draining 50 mAh is 1950.00 6. The remaining battery AA capacity after charging is 2000.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

5. Prepare for the role of interviewee

Answered: 1 week ago

Question

6. Secure job interviews and manage them with confidence

Answered: 1 week ago