i get stick with this problem *help please*

hi there,

i deal with exception handling problem >> the problem said rewrite the code *below* to continues to devide two numbers until the user enters the character q (as a numerator or denominator) to terminate program execution .

#include <iostream>
using namespace std;

int main ()
{

int numerator, denominator;
bool needDenominator = true;

cout << "Enter a numerator ( whole number only ): ";
cin >> numerator;
cout << "Enter a denominator ( whole number only ): ";

while (needDenominator)
{
cin >> denominator;
try
{
if (denominator == 0)
throw denominator;
}
catch( e)
{
cout << "A denominator value of " << e << " is invalid. " << endl;
cout << "please reenter the denominator (whole number only) : ";
continue;
}
cout << numerator << '%' << denominator << " = " << double(numerator)/double(denominator) << endl;
needDenominator = false;
}

system ("pause");
return 0;
}


help please :)
up
What is your problem?
Topic archived. No new replies allowed.