Comp242-hw3_mult - // Grkem Aksoy /...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // Grkem Aksoy / #include<iostream> #include<cstdlib> # using namespace std; u void level_1(); void level_2(); void displayResult(); v int level; int counter; int trueCounter; int userAnswer; int trueAnswer; double ratio; int main(){ i cout<<"Enter the level:\n"; // program asks user the level cin>>level; // the student inputs the level t switch(level) // depends on the user's answer { case 1: return level_1(); // program retruns the level_1 method break; case 2: return level_2(); // or program retruns the level_2 method break; } } void level_1(){ v for(int i=1;i<=10;i++) // method runs for 10 times to ask questions to the user { int onedigit1_random=1+rand()%10; // Using randomization function to produce a positive integer int onedigit2_random=1+rand()%10; // Using randomization function to produce a positive integer p cout<<"How much is "<< onedigit1_random <<" times "<< onedigit2_random <<"?\n"; // prints and asks the user the answer cin>>userAnswer; // takes the answer from user trueAnswer=onedigit1_random*onedigit2_random; // evaluates the correct answer if(userAnswer==trueAnswer){ // if the user's answer is true counter++; // increment counter by one to increase the number of the questions that is asked to the user...
View Full Document

Page1 / 5

Comp242-hw3_mult - // Grkem Aksoy /...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online