//Filename: hw6_functions.cpp Class: CS 1570
//Description: Contains function definitions for the quiz program
#include<cstdlib>
#include "hw6.h"
void greeting()
{
cout<<"\nWelcome to your doom!"<<endl;
}
char menu()
{
char choice;
cout<<"\nChoose your difficulty level"
<<"\n1. Easy"
<<"\n2. Moderate"
<<"\n3. Advanced"
<<"\n4. Super Easy (quit)"
<<endl;
cout<<"Choice: ";
cin>>choice;
return choice;
}
int randNum(const int min, const int max)
{
return rand()%(max - min + 1) + min;
}
float randNum(const float min, const float max)
{
int intMin = min/PRECISION;
int intMax = max/PRECISION;
return randNum(intMin, intMax)*PRECISION;
}
void showResults(const int numCorrect, const int numProblems)
{
int percent = 100.0*numCorrect/numProblems + .5; //.5 to round if needed
cout<<"\nYou got "<<numCorrect<<" correct out of "<<numProblems
<<" problems. That's "<<percent<<"%!"<<endl;
}
void signoff()
{
cout<<"\nHope you had fun."<<endl<<endl;
}