I'm very new to prgramming (in my first Programming class) and have a question about division. My project is to build a math flashcard program. I've gotten every thing else done but having trouble with the division. Where I'm having a problem is when the user inputs the correct answer to the hundredth place, the sum still says it's incorrect (probably because I can't seem to figure out how to setprecision to 2 for the sum to match the user input. Here's what I have so far (this example has the user enter the two number to be divided instead of random numbers to save space on this post). It works just fine when dealing with whole numbers. Again, I'm very new to this so you may ask why I did or didn't do something, it's becuase I'm an idiot and haven't caught on as quick :)
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char *argv[])
{
int number1 = 0;
int number2 = 0;
double user_answer = 0;
double sum = 0;
cout << "Enter 2 Numbers to be Divided: \n";
cin >> number1;
cin >> number2;
sum = static_cast<double>(number1) / number2;
cout <<"Enter Your Answer: ";
cin >> user_answer;
if(user_answer == sum)
cout << "Correct" << endl;
else cout << "Incorrect. Answer is: " << setprecision(2) << fixed << sum << endl;
system("PAUSE");
return EXIT_SUCCESS;
}