<?php
/*
Math Question
By CP309
GNU License:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, search it at the internet and read
it.
*/
//// Variables ////
$score = 1;
$wrscore = 1;
$qs = 1;
///////////////////
function questionask($question, $answer){
global $score;
global $wrscore;
global $qs;
$qs++;
echo($question . "\n");
echo("What is your answer? \n");
$ans = trim(fgets(STDIN));
if($ans==$answer){
echo("Correct! Your answer is $answer!\n");
$score++;
return $score;
} else {
echo("Wrong! The Answer is $answer !\n");
$wrscore++;
return $wrscore;
}
return $qs;
}
function add($v1, $v2){
$answerd = $v1 + $v2;
return $answerd;
}
function subtract($v1, $v2){
$answerd = $v1 - $v2;
return $answerd;
}
function multiply($v1, $v2){
$answerd = $v1 * $v2;
return $answerd;
}
function squareroot($s){
$ansz = $s * $s;
return $ansz;
}
echo("Welcome to Math Quiz Bot!\n Made by Kiko Perez! \n\n");
questionask("What is the Square root of " . squareroot(8) . "?", "8");
questionask("What is the Square root of " . squareroot(99) . "?", "99");
questionask("What is the Square root of " . squareroot(12) . "?", "12");
questionask("What is the Square root of " . squareroot(45) . "?", "45");
questionask("What is the Square root of " . squareroot(86) . "?", "86");
questionask("What is the Square root of " . squareroot(83) . "?", "83");
questionask("What is the 7 x 8?", multiply(7, 8));
questionask("What is the 9 x 5?", multiply(9, 5));
questionask("What is the 5 x 6?", multiply(5, 6));
questionask("What is the 5 x 2?", multiply(5, 2));
questionask("What is the 5 x 7?", multiply(5, 7));
questionask("What is the 4 x 10?", multiply(4, 10));
questionask("What is the 3 x 4?", multiply(3, 4));
questionask("What is the 7 x 2?", multiply(7, 2));
questionask("What is the 9 + 7?", add(7, 8));
questionask("What is the 9 + 5?", add(9, 5));
questionask("What is the 5 + 6?", add(5, 6));
questionask("What is the 5 + 2?", add(5, 2));
questionask("What is the 5 + 7?", add(5, 7));
questionask("What is the 4 + 10?", add(4, 10));
questionask("What is the 3 + 4?", add(3, 4));
questionask("What is the 7 + 2?", add(7, 2));
questionask("What is the 10 - 8?", subtract(10, 8));
questionask("What is the 9 - 5?", subtract(9, 5));
questionask("What is the 5 - 2?", subtract(5, 2));
questionask("What is the 120 - 56?", subtract(120, 56));
questionask("What is the 5643 - 546?", subtract(5643, 546));
questionask("What is the 123 - 10?", subtract(123, 10));
questionask("What is the 56 - 35?", subtract(56, 35));
echo("You have answered $qs Questions!\n You got $score corrects!\n You got $wrscore Mistakes!\n");
sleep(2);
echo("Thanks for taking the quiz!\n");
sleep(5);
exit;
?>
YOU MAY DISTRIUTE THIS TO ANYONE ELSE, PLEASE DO NOT REMOVE CREDIT OR ILL DELETE THIS