posted an update

include

include

include

include

include

include

include

typedef struct { int Opp; double numOne; double numTwo; double answer; char realOpp[50]; } questions;

questions createQuestion () { int lower = 0, upper = 100, count = 1; srand(time(0));

questions realQuestion;
/*
printf ("What opperation would you like to preform?\n");
scanf ("%c", &realQuestion.Opp);
printf("Input number one: \n");
scanf("%lf", &realQuestion.numOne);
printf("Input number two: \n");
scanf("%lf", &realQuestion.numTwo);
*///printf("Question 1 in realQuestion is %lf and Question 2 is %lf",realQuestion.numOne,realQuestion.numTwo);

for (int i = 0; i < count; i++)
{
    realQuestion.numOne = (rand() % (upper - lower + 1)) + lower;
    realQuestion.numTwo = (rand() % (upper - lower + 1)) + lower;
    realQuestion.Opp = ((rand() % (upper - lower + 1)) + lower) % 4;

}

if(realQuestion.realOpp == 0)
{
    realQuestion.answer = realQuestion.numOne + realQuestion.numTwo;
    strcat(realQuestion.realOpp, "plus");
}
else if(realQuestion.Opp == 1)
{
    realQuestion.answer = realQuestion.numOne - realQuestion.numTwo;
    strcat(realQuestion.realOpp, "minus");
}
else if(realQuestion.Opp == 2)
{
    realQuestion.answer = realQuestion.numOne * realQuestion.numTwo;
    strcat(realQuestion.realOpp, "times");
}
else
{
    realQuestion.answer = round(realQuestion.numOne / realQuestion.numTwo);
    strcat(realQuestion.realOpp, "divided by");
}

return realQuestion;

}

int main() { double userAnswer; int count = 0; double percentage; char grade; bool first = true; for(int i = 0; i < 10; i++) { questions Q1 = createQuestion(); char num1[50]; char num2[50]; char Opp[50]; char equation[50]; char intro[200]; char qNum[50];

    // TTS introduction on first iteration
    if (first) 
    {
        strcpy(intro, "This is a text-to-speech based tool meant to help users practice their arithmetic using only hearing,");
        first = false;
    }

    strcpy(intro, "Question ");
    strcpy(qNum, itoa(i + 1, qNum,10));
    strcat(intro, qNum);

    // TTS question number
    char introCommand[500];
    strcpy(introCommand, "espeak -v m1 -s 140 \"");
    strcat(introCommand, intro);
    strcat(introCommand, "\"");
    system(introCommand);

    // Converting the numbers to strings
    strcpy(num1, itoa(Q1.numOne,num1,10));
    strcpy(num2, itoa(Q1.numTwo, num2, 10));
    // strcpy(Opp, &Q1.realOpp);
    strcat(num1, Q1.realOpp);
    strcat(num1, num2);

    // TTS asks question
    strcpy(equation, num1);
    strcat(equation, "is equal to what?");
    char charCommand[100];
    strcpy(charCommand, "espeak -v m1 -s 140 \"");
    strcat(charCommand, equation);
    strcat(charCommand, "\"");
    system(charCommand);

    printf("What is %.1lf %c %.1lf?\n", Q1.numOne, Q1.realOpp, Q1.numTwo);
    scanf("%lf", &userAnswer);

    if (userAnswer == Q1.answer)
    {
        count++;
        printf("You got it right!\n");
    }
    else
    {
        printf("Incorrect\n");
    }
}

percentage = (count/10.0)*100;

if (percentage>=90)
{
    grade = 'A';
}   
else if (percentage>=80)
{
    grade = 'B';
}
else if (percentage>=70)
{
    grade = 'C';
}
else if (percentage>=60)
{
    grade = 'D';
}
else
{
    grade = 'F';
}

printf("You got %d correct, so your grade is %c",count,grade);

return 0;

}

Our code for incorporating TTS into the quiz. We ran out of time and we had a lot of complications with team member's availability and such, so we weren't able to finish the project fully. There are some bugs in both codes that have yet to be worked out but this is what we have thus far. Our team is me, Enlun Yin, Othmane Harraq, Ryan Chan, and Gaurab (We are all freshman and just wanted to get some experience making a project together, having fun, and being in an environment with higher level programmers and absorb as much information as possible. Thank you OwlHacks for a great time!!!!! :)

Log in or sign up for Devpost to join the conversation.