Hello, I am new to programming in C++. My first project for my CS class is to write a program that will calculate the area of a yard, the area of a house and then figure out how many bags of grass seed are needed for the yard (each bag of seed covers 287 sq. feet). Since you cannot buy a piece of a bag of seed, if there is a remainder, the answer must be rounded up. To do this, I used an if else statement as follows:
if ( (bags_of_seed % 287) == 0 )
{
cout << "\nYou need " << bags_of_seed;
cout << " bags of seed. " << endl;
}
else
{
cout << "You need " << bags_of_seed++;
cout << "bags of seed.\n";
}
I am using nano. For some reason my answer will not round up if there is a remainder. I am simply trying to say that if the remainder is 0, I do not need another bag, but if the remainder is not 0, I do need another bag. Will someone please help me figure out what I'm doing wrong? Thanks a lot for the feedback.
hey I figured out my problem, I guess it would have helped if I had shown you my other variables but I was using bags_of_seed instead of area_for_seed. Thanks for the help everyone