Jump to content

kaveman50

Members
  • Posts

    60
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kaveman50's Achievements

Member

Member (2/5)

0

Reputation

  1. Does anyone know how to do (or at least help me get started on) a binary search? I have to create a list of 25 names in alphebetical order. Create a binary search program that searches for an input name. Tell the user whether or not the name was found. The names i'll use will be. $arr=array('Allen', 'Brad', 'Chris', 'Drake', 'Eugene',' Frank', 'Greg', 'Hank', 'Ingrid', 'Jim', 'Kraig', 'Lee', 'Molly', 'Nathan', 'Otis', 'Peter', 'Quame', 'Rolland', 'Sean', 'Tiffany', 'Utopia', 'Venus', 'Walley', 'Xephinorgi', 'Yullanda', 'Zeus');
  2. I'm probably really off. It's just coming up blank. I guess I should just start over...
  3. ?? This is what I have so far. I'm not sure where to go from here though. <? $grades=array(); $file=fopen("grades.txt","r") or exit("Unable to open file!"); $file=fopen("HIGHER.txt","r") or exit("Unable to open file!"); $file=fopen("LOWER.txt","r") or exit("Unable to open file!"); while(!feof($file)) { $f = fgets($file); array_push($grades, $f); } $arr[$i] = explode('", ', $grades[$i]); fclose($file); ?>
  4. How could I have a main text file, for instance PRIMARY.txt that has scores of certain tests, but then make 2 more txt files using php that'll make it so that it'll show scores lower than 50 in a file called lower.txt and the scores greater than 50 in a file called higher.txt? Anyone know?
  5. Thanks! The splice worked. I'm not sure why the shift wasn't working. Anyways, no more questions on this program again I promise.
  6. Sorry I meant dropping the 2 lowest scores.
  7. It just displays the average without it rounded off, though.
  8. Oh yeah how would I drop the 2 lowest scores?
  9. Oh I didn't see the array POST you added in the second time. My bad. Thanks for the help.
  10. I'm sorry but I still don't really get what you mine by putting a blank [] after the num. I tried it once and it gave me even more errors. The most recent code I have doesn't say any errors when I click submit, but it returns zero. <form method='post' action=''> Enter Student's Name: <br/> <input type="text" name="num1" value = " " /> <br/> <br/> Enter Seven Tests Scores Here: <br/><input type="text" name="num1" value = "<?=$_POST['num']?>" /> <br/><input type="text" name="num1" value = "<?=$_POST['num']?>" /> <br/><input type="text" name="num1" value = "<?=$_POST['num']?>" /> <br/><input type="text" name="num1" value = "<?=$_POST['num']?>" /> <br/><input type="text" name="num1" value = "<?=$_POST['num']?>" /> <br/><input type="text" name="num1" value = "<?=$_POST['num']?>" /> <br/><input type="text" name="num1" value = "<?=$_POST['num']?>" /> <br/><input type='Submit' name='Submit' value="Submit" /> </form> <? $arr=array($_POST['num']); function getAverage($arr) { asort($arr); array_shift($arr); array_shift($arr); return array_sum($arr) / count($arr); } if(isset($_POST['Submit'])) { echo array_sum($arr) / count($arr); } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.