diff options
author | WWDillingham WesleyDillingham <wwdillingham@sugarlabs.org> | 2009-07-01 00:15:02 (GMT) |
---|---|---|
committer | WWDillingham WesleyDillingham <wwdillingham@sugarlabs.org> | 2009-07-01 00:15:02 (GMT) |
commit | 77b4931c3c7e27a3ca27d8f2dbb56727af0d71a3 (patch) | |
tree | 097af0e49e7ffcfc3a9fe8128be0949b47d459fa | |
parent | de38541e15e07959b9cef435be3390aa5c27b23f (diff) |
updated a comma issue in if-statements
-rw-r--r-- | order_of_operations_parser.php | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/order_of_operations_parser.php b/order_of_operations_parser.php index a8a8089..63e5fa6 100644 --- a/order_of_operations_parser.php +++ b/order_of_operations_parser.php @@ -21,7 +21,7 @@ $fp = fopen("./Student.dat", "r"); if(!$fp) die ("Cannot open the file"); -/* Break Each line of the file into its own array element - will have to parse each array element to obtain fields */ +//Break Each line of the file into its own array element - will have to parse each array element to obtain fields $lines = file($fp); @@ -117,7 +117,7 @@ for (i=0;i<=$numRecords;i++) } //Matches equations with ONLY SUBTRACTION - if (preg_match($regexp, $equation) && !preg_match("+", $equation), && !preg_match("/", $equation), && !preg_match("*", $equation)) + if (preg_match($regexp, $equation) && !preg_match("+", $equation) && !preg_match("/", $equation) && !preg_match("*", $equation)) { $only_subtraction[tok[2]]++ @@ -142,7 +142,7 @@ for (i=0;i<=$numRecords;i++) //Matches equations with ONLY DIVISION - if (preg_match($regexp, $equation) && !preg_match("+", $equation), && !preg_match("-", $equation), && !preg_match("*", $equation)) + if (preg_match($regexp, $equation) && !preg_match("+", $equation) && !preg_match("-", $equation) && !preg_match("*", $equation)) { $only_division[tok[2]]++ @@ -166,7 +166,7 @@ for (i=0;i<=$numRecords;i++) } //Matches equations with ONLY Multiplication - if (preg_match($regexp, $equation) && !preg_match("+", $equation), && !preg_match("/", $equation), && !preg_match("-", $equation)) + if (preg_match($regexp, $equation) && !preg_match("+", $equation) && !preg_match("/", $equation) && !preg_match("-", $equation)) { $only_multiplication[tok[2]]++; @@ -175,12 +175,45 @@ for (i=0;i<=$numRecords;i++) $only_multiplication_correct[tok[0]]++; } } - - - - } + + //need to cycle through each operation again to check for compound-operation equations + $regexp="+"; //we will start with addition + + if(preg_match($regexp, $equation) && (preg_match("+", $equation), preg_match("/", $equation), && preg_match("-", $equation))) +/* + #Determine if it is a compound operation if so increment by one, this requires 4 if's as we have to check if each of them exists in +# conjuntion with another. +#Keep track of total compounds and compounds correct. +#Else-if structure required because if stringed If's were used each compound match would register twice. +*/ + +/* + if ( match($3, /\//) && ( match($3, /[0-9]\-[0-9]/) || match($3, /\+/) || match($3, /\*/) ) ) +141 { +142 compound[$2]++ +143 +144 if ($4 == "1") #if correct +145 { +146 compound_correct[$2]++ +147 } +148 } +149 else if ( match($3, /[0-9]\-[0-9]/) && (match($3, /\//) || match($3, /\+/) || match($3, /\*/) ) ) +150 { +151 compound[$2]++ +152 +153 if ($4 == "1") #if correct +154 { +155 compound_correct[$2]++ +156 } +157 +158 } +*/ + + + + } |