Advertisement
BladeMechanics

Phase 1

Oct 13th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.95 KB | None | 0 0
  1.     for (rounds = 10; rounds; rounds--)
  2.     {
  3. break; //debug skip
  4.         system("cls");
  5.         gui(0);
  6.         if (rounds>1) printf("\n\n\t\tEquation %d", 10-rounds + 1);
  7.         else printf("\n\n\t\tFinal Equation");
  8.         printf("\n\n\t\tCurrent Score : %d\n", score);
  9.         firstNum = rand() % 10 + 1;
  10.         secondNum = rand() % 10 + 1;
  11.         operand = rand() % 2;
  12.         timer = clock(); //timer begins
  13.         if (operand)
  14.         {
  15.             answer = firstNum + secondNum;
  16.             printf("\n\n\tThe sum of %2.0f + %2.0f is:  ", firstNum,secondNum);
  17.         }//True(1)=Addition
  18.         else
  19.         {
  20.             answer = firstNum - secondNum;
  21.             printf("\n\n\tThe difference of %2.0f - %2.0f is:  ", firstNum, secondNum);
  22.         }//subtraction
  23.         fflush(stdin);
  24.         scanf_s("%f", &userAnswer);
  25.         timer = float((clock()-timer)/1000);
  26.         if      (answer == userAnswer)
  27.                     printf("\n\tYour answer is correct!\n\t");
  28.         else if (answer > userAnswer)
  29.             {  
  30.                     printf("\n\tYour answer is too low! \n\tCorrect Answer: %2.0f\t",answer);
  31.                     timer += 5;
  32.             }  
  33.         else
  34.             {
  35.                     printf("\n\tYour answer is too high! \n\tCorrect Answer: %2.0f\t",answer);
  36.                     timer += 5;
  37.             }
  38.                 /*--------------SCORE EVALUATION--------------*/
  39.         if (timer < 1)      {   score += 10;    printf("Score +10");}
  40.         else if (timer < 2) {   score += 9;     printf("Score +9");}
  41.         else if (timer < 3) {   score += 8;     printf("Score +8");}
  42.         else if (timer < 4) {   score += 7;     printf("Score +7");}
  43.         else if (timer < 5) {   score += 6;     printf("Score +6");}
  44.         else if (timer < 6) {   score += 5;     printf("Score +5");}
  45.         else if (timer < 7) {   score += 4;     printf("Score +4");}
  46.         else if (timer < 8) {   score += 3;     printf("Score +3");}
  47.         else if (timer < 9) {   score += 2;     printf("Score +2");}
  48.         else if (timer < 10){   score += 1;     printf("Score +1");}
  49.         else                {   score += 0;     printf("Score +0");}
  50.                 /*--------------SCORE EVALUATION--------------*/
  51.         if (rounds > 1)
  52.         {
  53.             printf("\n\n\tNext round in 3");
  54.             Sleep(1000);
  55.             printf("...2");
  56.             Sleep(1000);
  57.             printf("...1");
  58.             Sleep(1000);
  59.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement