w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
convert a 4-digit military time into the standard 12 hour time format
if (pm = true)
if (pm = false)

A single equal sign is an assignment. You want to do a comparison:

if (pm == true)
if (pm == false)

These could also be written more idiomatically as:

if (pm)
if (!pm)

That's the main problem. Another is your logic for setting pm. You only need a single if statement, with the line subtracting 1200 placed inside the pm = true block.

if (milTime < 1200)
{
    pm = false;
}
else
{
    pm = true;
    milTime -= 1200;
}

There are a few other bugs that I'll leave to you. I trust these corrections will get you a bit further, at least.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.