writing a program for a quiz. what happens is that you are given a menu and you choose the level of difficulty you want. Then the next menu asks if you want to do random operator or asks you to enter an operator. i'm confused as to how i write code for my program to display the problems using a random operator. this is what i have in my functions.cpp file so far. also the error functions.cpp:89: error: expected initializer before â.â token is coming up in line 89.
Code:
#include <iostream>
#include "functions.h"
#include <cstdlib>
using namespace std;
void greet()
{
cout <<"Hello User! Welcome to..."<< endl;
return;
}
void signoff()
{
cout <<"Goodbye User!" <<endl;
return;
}
int menu()
{
int option;
int level;
do
{
cout <<"Please select difficult level"<< endl
<<"1. Easy"<< endl
<<"2. Moderate"<< endl
<<"3. Advanced"<< endl;
cin >> option;
if ( option < 1 || option > 3 )
{
cout << option <<" is not a valid option."<< endl;
}
}while ( option < 1 || option > 3 );
return option;
if ( option == 1)
{
level = 1;
}
if ( option == 2)
{
level = 2;
}
if ( option == 3 )
{
level = 3;
}
return level;
}
int operatorChoice()
{
int choice;
do
{
cout <<"Please choose an operator choice"<< endl
<<"OPERATOR CHOICE"<< endl
<<"1. I feel lucky - randomly picked operator"<< endl
<<"2. Pick a particular operator"<< endl;
cin >> choice;
if ( choice < 1 || choice > 2 )
{
cout << choice <<"is not a valid option."<< endl;
}
}while ( choice < 1 || choice > 2 );
switch ( choice )
{
case 1:
Problem generateProblemRand();
break;
case 2:
Problem generateProblem();
break;
}
return choice;
}
Problem generateProblemRand()
{
Problem result;
char problem.m_arithmOp[4] = {'-','+','%','*'};
return result;
}
Problem generateProblem()
{
cout<<"Please enter the operator you would like to use"<< endl;
cin >> problem.m_arithmOp;
}
this is my struct in my header file
Code:
struct Problem
{
int m_number1;
int m_number2;
int m_answer;
int m_level;
char m_arithmOp;
} problem;