Battery Charge Indicator - MATLAB Cody - MATLAB Central

Problem 60221. Battery Charge Indicator

Difficulty:Rate
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

44.23% Correct | 55.77% Incorrect
Last Solution submitted on May 05, 2025

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...
Dive Into Hands-On Learning at MATLAB EXPO 2025 – Register Now!
Get ready to roll up your sleeves at MATLAB EXPO 2025 –...
0

Problem Recent Solvers20

Suggested Problems

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!