#include <Windows.h>
#include <iostream>
usingnamespace std;
int main()
{
while (true)
{
SYSTEM_POWER_STATUS status;
GetSystemPowerStatus(&status);
int Battery = status.BatteryLifePercent;
cout << "Battery status is:";
if (Battery <= 20) //if % is less than or equal to 20
{
cout << " low, your should consider charging your battery" << endl << "your batter percentage is " << Battery << endl;
Sleep(10000);//wait 10000 seconds
continue;//restart program after 1000 seconds
}
elseif (Battery >= 21 && Battery <= 50) //if % is greater than or equal to 50 and less than or equal to 79
{
cout << " ok, should still consider charging your battery" << endl << "your batter percentage is " << Battery << endl;
Sleep(10000);//wait 10000 seconds
continue;//restart program after 1000 seconds
}
elseif (Battery >= 51 && Battery <= 79) //if % is greater than or equal to 50 and less than or equal to 79
{
cout << " average, should still consider charging your battery, but not needed" << endl << "your batter percentage is " << Battery << endl;
Sleep(10000);//wait 10000 seconds
continue;//restart program after 1000 seconds
}
elseif (Battery >= 80 && Battery <= 99) //if % is greater than or equal to 80 and less than or equal to 99
{
cout << " good, shouldnt need to charge your battery" << endl << "your batter percentage is " << Battery << endl;
Sleep(10000);//wait 10000 seconds
continue;//restart program after 1000 seconds
}
elseif (Battery == 100) //if % is egual to 100
{
cout << " great, battery is full" << endl << "your batter percentage is " << Battery << endl;
Sleep(10000);//wait 10000 seconds
continue;//restart program after 10000 seconds
}
else//if no reading
{
cout << " not working, or no battery" << endl;
Sleep(10000);//wait 10000 seconds
continue;//restart program after 10000 seconds
}
if (BATTERY_FLAG_CHARGING)//if charging
{
cout << "battery is charging" << endl;
}
else//if not charging
{
cout << "not charging, running off battery" << endl;
}
}
}