rograming language Java. Define a class that represents a smartphone and in particular its battery. The battery has a capacity in mAH (milliamp-hours). This would be a parameter to your constructor. Several features of the phone consume battery power: the screen, voice calling, wifi, and Bluetooth. These can be on or off. When on, they use power as given in the following table: screen 500 mA voice 300 mA wifi 200 mA Bluetooth 100 mA The battery life (in hours) of the phone is its capacity (in mAH) divided by the total power use of all the features that are turned on (in mA). Your class should have a method that computes and returns the battery life given the current settings of the features. The purpose of this question is for you to get practice with objects having both state and behavior. Hint: you should use boolean instance variables to represent the states of each of the four features outlined above. Look up a phone’s battery capacity (for example, 2200 mAH) and write a short main method which demonstrates the features of your class. Your main method should create an instance of a phone with that capacity and print the battery life with all features off. It should then turn some features on and/or off and print the battery life with those settings.
Programing language Java.
Define a class that represents a smartphone and in particular its battery. The battery has a capacity in mAH (milliamp-hours). This would be a parameter to your
constructor. Several features of the phone consume battery power: the screen, voice
calling, wifi, and Bluetooth. These can be on or off. When on, they use power as
given in the following table:
screen 500 mA
voice 300 mA
wifi 200 mA
Bluetooth 100 mA
The battery life (in hours) of the phone is its capacity (in mAH) divided by the total
power use of all the features that are turned on (in mA). Your class should have a
method that computes and returns the battery life given the current settings of the
features. The purpose of this question is for you to get practice with objects having
both state and behavior. Hint: you should use boolean instance variables to represent
the states of each of the four features outlined above.
Look up a phone’s battery capacity (for example, 2200 mAH) and write a short main
method which demonstrates the features of your class. Your main method should
create an instance of a phone with that capacity and print the battery life with all
features off. It should then turn some features on and/or off and print the battery
life with those settings.
According to the information given:-
We have to follow the instruction and program in java.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images