Problem 60221. Battery Charge Indicator
Write a function called battery_charge that visually represents the charge of a battery.
The function takes an integer parameter percentage between 0 and 100 representing the battery charge percentage. It returns an array bars where each element contains a single character (visually representing the battery charge).
The array starts with '[', ends with ']', and contains from 0 to 10 characters '❚' or ' ' (space) to visually represent the battery charge. The number of '❚' characters is rounded, meaning that for percentages like 9% and 11%, only one ❚ will be used.
Solution Stats
Problem Comments
-
1 Comment
Christian Schröder
on 5 May 2024
As before, thank you very much for submitting all these interesting new problems, minnolina!
Solution Comments
Show commentsProblem Recent Solvers10
Suggested Problems
-
Replace NaNs with the number that appears to its left in the row.
2968 Solvers
-
Make an awesome ramp for a tiny motorcycle stuntman
631 Solvers
-
Create logical matrix with a specific row and column sums
301 Solvers
-
Split a string into chunks of specified length
1669 Solvers
-
Test Problem; Create a 5x5 array containing all ones
380 Solvers
More from this Author53
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!