/* When I run this code the random numbers that are supposed to be generated will not cout. Any suggestions would be a great help!*/

int main()
{
	Fraction operand1, operand2, resultant;
	int a, b, c, n, d;
	char op, choice;
	//char opchar:
	srand(time(0));
	system("cls");
	
	//a.setAll(1); //1 indicates that it's the 1st fraction
	//b.setAll(2); //2 indicates that it's the 2nd fraction
	
	cout << "Enter a menu selection (1 - 4)\n"<<"1 - Addition\n"<<"2 - Subtrtaction\n"<<"3 - Multiplication\n"<<"4 - Division\n"<<endl;
	cin >> choice;
	
	switch (choice)
	{
		case 1:
			op = FRAC_ADD;
			break;
		case 2:
			op = FRAC_SUB;
			break;
		case 3:
			op = FRAC_MUL;
			break;
		case 4:
			op = FRAC_DIV;
			break;
		//default: //if operator is illegal shut program down 
			cout << "Invalid operator." <<endl;
			return (0);
	}
	
	/*if ((a.den == 0) || (b.den == 0)) //fraction undefined if so
		cout << "\n\nFraction is undefined.";
	else //else fraction can be worked with
	{
		c = Fraction_Do_Op(op, a, b);
		cout << "\n\n";
		c.reduce(); //reduce to simplify fraction
		c. DisplayMixed();
	}*/
	
	
	do{
		n = 1 + (rand() % 11);
		d = 2 + (rand() % 11);
		operand1.setNum(n);
		operand1.setDen(d);
		
		n = 1 + (rand() % 11);
		d = 2 + (rand() % 11);
		operand2.setNum(n);
		operand2.setDen(d);
		
		n = operand1.getNum() * operand2.getNum();
		d = operand1.getDen() * operand2.getDen();
		
		resultant.setNum(n);
		resultant.setDen(d);
		resultant.reduce();
		
		do
		{
			cout <<"\n\nWhat is ";
			//operand1.print();
			cout << " / ";
			//operand2.print();
			cout << "?";
			cout<<"\n\n(Enter numerator / denominator)YOUR ANSWER MUST BE IN REDUCED FORM ->";
			cin >> n >> op >> d;
		}while(n != resultant.getNum() || d != resultant.getDen());
		
		
		cout <<"\nCORRECT!!! Enter q to quit, Enter c to continue ->";
		cin >> choice;
	}
	while(choice != 'q');
	
	return 0;
	
}

Please give a better description of the problem than "random numbers that are supposed to be generated will not cout"

That makes little sense.

I am using overloaded operators in a fraction program. Part of the program is to have random numbers generated to the screen for the user to guess the correct answer. I can not get the random numbers to print to the screen. Everything else will.

Sorry, I was asking for details, not concepts. What, when, where type of information. With 83 lines of code going all over the place, pinpoint the problem area.

60-62

I see no definition of resultant.setNum(n); so maybe it doesn't do what you want it to do.

66-72

These lines output nothing but text then input 3 values.

This article has been dead for over six months. Start a new discussion instead.