#include <cs50.h>
#include <stdio.h>
int main(void)
{
// TODO: Prompt for start size
float startSize;
do
{
startSize = get_int("Start Size: ");
}
while (startSize < 9);
// TODO: Prompt for end size
float endSize;
do
{
endSize = get_int("End Size: " );
}
while (endSize < startSize);
// TODO: Calculate number of years until we reach threshold
int years = 0;
while (startSize < endSize)
{
startSize += (float) startSize / 12;
years++;
}
// TODO: Print number of years
printf("Years: %i\n", years);
}
These are the error I get:
:( rejects invalid populations and then handles population 9
expected "Years: 8", not "Years: 9\n"
:( rejects invalid populations and then handles population 20
expected "Years: 20", not "Years: 21\n"
:( handles starting population of 100
expected "Years: 115", not "Years: 116\n"
It looks like I am getting an extra year. Please help?