here is what i have so far, it compiles and runs great except for the fact that when i enter 'n' it doesn't stop the loop, any help is greatly appreciated!
/* Write a program that prompts the user for two
numbers – the dividend and the divisor – and
then displays the division of the dividend by
the divisor. Your function must be called
displayDivision and will check that the divisor
is not zero before attempting the division. If
the divisor is zero, your function will display
the error message shown below. Your program will
then ask the user if s/he wants to continue. If
the user enters a 'y' (either upper or lower case),
continue to ask the user for the next dividend and
divisor. Use the screen shot below as a guide.
*/
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
double displayDivision(double dividend, double divisor)
{
if(divisor != 0)
{
double divisionAnswer;
divisionAnswer = dividend/divisor;
cout << divisionAnswer << endl;
return divisionAnswer; }
else { cout << "Error: Attempt to divide by zero!" << endl;
return 0; }
}
int main()
{
char qAnswer;
do
{ double dividend, divisor; cout << "Enter the dividend: ";
cin >> dividend;
cout << "Enter the divisor: ";
cin >> divisor;
displayDivision(dividend, divisor);
char qAnswer;
cout << "Do you want to continue (y/n)? ";
cin >> qAnswer;
}
while (qAnswer = 'y');
}