Php Calculator That Calculates Genetic Percentages? - I need help finding sites or tutorials.

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Php Calculator That Calculates Genetic Percentages? - I need help finding sites or tutorials.

TheChosenDarkness
Okay, I have created, looked, and generally studied simple PHP calculators. However, I can not seem to find any tutorials on how to create a genetic calculator. One that calculates genetic percentages similar to that of Punnette Squares. I have seen plenty of websites that have these types of calculators, but I have yet to see any websites offer tutorials on how to create these types of calculators. So.. does anyone know of any tutorials I can find or sites that might have the tutorial I am looking for? Maybe even a tutorial here?

Reason for asking: I am creating a website, simulation game, and one of the aspects of the game is calculating the colors of the offspring from a certain pair.

Any help on the subject is greatly appreciated.


Thanks in advance,
TCD

Reply

galexcd
Well its been a long time since I've seen or used punnette squares, and I'm sure they are much more complicated than the simple 4 block ones that I learned, but I'll do a basic one for you.

So if I recall correctly you have dominant and recessive traits, such as dark hair or blond hair. And lets say dark is dominant. So we'll have this:

DD+bb=
100% to be Db

Db+Db=
25% to be DD
50% to be Db
25% to be bb

Db+bb=
50% to be Db
50% to be bb

Correct? (If I'm wrong tell me because it's been a while)

Anyway I would suggest an object oriented approach if you are going to be having different plants (or animals) with different traits. So first make the class life.
CODE
class life{
function __construct($dom,$res){//constructors are new in php 5 so don't do this step if you are working with an older version
$this->dom=$dom;
$this->res=$res;
}
//Returns a life object when mating this object and the input object
function mate($life){
switch(rand(0,3)){
case 0:
return new life($this->dom,$life->dom);
case 1:
return new life($this->res,$life->dom);
case 2:
return new life($this->dom,$life->res);
case 3:
return new life($this->res,$life->res);
}

}

}


And that should do it. This code was not tested yet. Post back with any errors you find.

 

 

 


Reply

TheChosenDarkness
Yes. Exactly on the example about Punnette Squares. =] Also, I tested the code below and it works just fine. Now I just need to add a form to it so people can choose the color or genetics to generate the outcome. Correct?

My hosting company just recently upgraded to PHP 5. So.. I am still working on understanding certain aspects of PHP 5. Since I have been mainly studying PHP 4 and testing PHP 4.

Thank you again and the code was very helpful. ^^


TCD


QUOTE(alex7h3pr0gr4m3r @ Mar 12 2008, 01:27 PM) *
Well its been a long time since I've seen or used punnette squares, and I'm sure they are much more complicated than the simple 4 block ones that I learned, but I'll do a basic one for you.

So if I recall correctly you have dominant and recessive traits, such as dark hair or blond hair. And lets say dark is dominant. So we'll have this:

DD+bb=
100% to be Db

Db+Db=
25% to be DD
50% to be Db
25% to be bb

Db+bb=
50% to be Db
50% to be bb

Correct? (If I'm wrong tell me because it's been a while)

Anyway I would suggest an object oriented approach if you are going to be having different plants (or animals) with different traits. So first make the class life.
CODE
class life{
function __construct($dom,$res){//constructors are new in php 5 so don't do this step if you are working with an older version
$this->dom=$dom;
$this->res=$res;
}
//Returns a life object when mating this object and the input object
function mate($life){
switch(rand(0,3)){
case 0:
return new life($this->dom,$life->dom);
case 1:
return new life($this->res,$life->dom);
case 2:
return new life($this->dom,$life->res);
case 3:
return new life($this->res,$life->res);
}

}

}


And that should do it. This code was not tested yet. Post back with any errors you find.


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. how to develop calculator using php and mysql - 31.98 hr back. (2)
  2. how to develop calculator using php and mysql - 32.14 hr back. (2)
  3. php mysql random percentages - 45.41 hr back. (1)
  4. random php percentages - 60.28 hr back. (1)
  5. hair color calculator - 85.28 hr back. (2)
  6. simple php calculator - tutorial - 89.92 hr back. (1)
  7. php calculation function tutorial - 99.92 hr back. (1)
  8. genetic hair color calculator - 104.91 hr back. (1)
  9. genetics percentages - 132.97 hr back. (1)
  10. calculation and switch in php - 144.60 hr back. (1)
  11. php calculator - 145.06 hr back. (1)
  12. wml code for calculator - 154.48 hr back. (1)
  13. php percentages - 43.53 hr back. (2)
  14. genetics hair calc calculator - 212.76 hr back. (1)
Similar Topics

Keywords : php, calculator, calculates, genetic, percentages, finding, sites, tutorials,

  1. Xampp How Can I Generate "automatic Start Sites"
    (7)
  2. Know Of Any Good Php Tutorials?
    (9)
    Hi all this well be my first posting so hopefully I can get some good advise here. Can anyone tell
    me were there is a very good tutorial for php. I am good at self teaching from tutorials but i do
    hear php can be difficult so if anyone can lead me to a php tutorial that is as basic as possible i
    would be very pleased. p.s hopefully this post is in the right area :/....
  3. Best Sites For Learning Php-mysql
    (4)
    Hi I was reminded of this earlier by a post in a topic, meant to post it but forgot and the topic on
    php books reminded me. Well anyway there is tyhschools for learning php (unless someone else knows
    a better 1) but I wan't to know what is the best site for using php with mysql (using
    phpmyadmin) also whats the difference between postgresql and mysql? though I must admit the
    postgresql version of phpmyadmin whatever it's called looks better (visually)!....
  4. The Artists Tutorials :mysql Basic Commands
    The Artists is an online programming unit and gfx designing clan. (0)
    Let's Talk about basic mysql commands used in php. I will now show you a list of the most common
    MySQL FUNCTIONS : QUOTE mysql_connect(MySQL server name,username,password) - opens a connection
    to a MySQL server. mysql_select_db(database name,connection id) - selects a database residing on
    the MySQL server. The database name parameter referes to an active database on the MySQL server that
    was opened with the mysql_connect function. The connection identifier is a reference to the current
    MySQL connection. mysql_query(sql query) - sends a query to the currently ac....
  5. Papular Wap Scripts 4 Your Sites
    collection of WAP scripts (3)
    Redirect script webbrowser from wap to web and wapbrowser from web to wap. CODE <?
    $htmlredirect = "http://kralj.frih.net"; $wmlredirect =
    "http://kralj.r8.org";
    if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0){
    header("Location: ".$wmlredirect);} else{ header("Location:
    ".$htmlredirect); exit;} ?>
    ================================================================== Graphic counter. !!!
    Dont forget to create count....
  6. Simple Text Counters
    Counters i use on wap sites ;-) (15)
    First create a dir "counters" in root add to it dailyhits.txt, hits.txt, online.txt an CHMOD 0777,
    place this on index: CODE //online counter $tim = 120+time(); $time =
    time(); $f = "counters/online.txt"; $nusk = file($f);
    $sk = count($nusk); $in = $HTTP_USER_AGENT.$REMOTE_ADDR; $fp =
    fopen($f, "w+"); for($i=0; $i<$sk; $i++) {
    list($nix, $timf) = explode("|", $nusk[$i])....
  7. Php Scripts Free For Every One
    list of the best php scripts sites (12)
    so what's you favourites php scripts sites? mine are : 1- hotscript 2- phpbuilder 3-
    developershed 4- internet so what's yours? /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" />....
  8. Finding Data In Meta Tags
    using php to search Meta Tags for data (0)
    In the Head portion of an Html file, there are usually several Meta Tags that contain data about
    various things, like the tag for keywords, an Author's name or maybe a description field. Here
    are two example Meta tags: HTML meta name =" Keywords " content=" keyword1, keyword2 " />
    meta name =" Description " content=" A Description of the file's content is here " /> So,
    what I have a question about concerns checking a file to see what information is included in these
    tags and using that information as variables or content in the output of the page....
  9. Anyone Know Any Good Sites To Learn Php
    (17)
    ive tried many sites like www.w3school.com. Ive tried some of the guides in the forums here. Ive
    triedwww.php.com. If u have any other sites please tell me and make it a site that is easy to learn
    php and to understand wat they are saying please. ANd maybe a site to learn mySQL but i am using
    w3school for mySQL....
  10. Reading Site's Source Code With Php
    is this possible? (8)
    Hey guys. I want to know if it's possible to read a site's source code using PHP. Would
    using $blah = file(http://google.com); work? I want to make a script that will retrieve the
    comic of the day from http://comics.com/ . Currently, I have another source, http://ucomics.com/ ,
    but that site doesn't have some of the ones that I want. The thing is, http://ucomics.com/
    uses an easy file name for each comic in their comic of the day. Here's an example of the file
    name: ga050826.gif. That is for August 26th, 2005. Simple stuff. http://comics.com/....
  11. Coding Your Sites ?
    Coding your sites (20)
    What kind of coding do you use on your sites? I have so far learnt using a little tables and
    div/css. /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> ....
  12. Php Tutorials
    plz help me finding a tutorial for php (7)
    does anybody know a website or abook or something where i can learn PHP. i want to make a website
    but HTML is too soft:P i want more options and i think that is possible in php. And another question
    is how can i make a phpnuke style?? plz post in this forum:) (I didný post in the tutorials forum
    becaues i thought it woulkd be a really long TUT) /wink.gif' border='0'
    style='vertical-align:middle' alt='wink.gif' /> ....
  13. Where Did You Guys Learn Php?
    Any good suggestions on were i could start? (tutorials) (21)
    Well im reading this book on php for beginers, and i thought, what if there is something better out
    there, b/c i bought this book like 2 years ago, but really havent read it, so i was just wondering
    if you guys new a good tutorial, or were did you guys learn PHP? Any help is appreciated.....
  14. Php Dynamic News Updating Using Mysql
    changing a sites news using MySQL and PHP (3)
    Hey everyone. It appears to me that everyone really know what they are doing in this forum and im a
    pretty new to this PHP and MySQL combo. I know some PHP but not MySQL....I am trying to make a new
    website but i want to be able to go to a certain update page and change the news on the main index.
    For example: - The main page show news updates of the last 10 post. - I go to the update page
    and then fill in the form and it will add this post to the top of the list and still only print the
    top 10. I have no clue how to do this with MySQL. At the moment i am doing it u....
  15. Many Php Script Sites
    (16)
    Hi I find many sites has PHP scripts :: http://www.proxy2.de/scripts.php http://www.free-php.net
    http://knubbe.t35.com/ http://www.ngcoders.com/ http://www.oxyscripts.com/
    http://www.phparena.net/ http://www.1phpstreet.com/ http://px.sklar.com/
    http://www.scoznet.com/ http://php.resourceindex.com/ /blink.gif' border='0'
    style='vertical-align:middle' alt='blink.gif' /> ....
  16. Php Calculator
    Simple but cool. (17)
    Hello all, I was eally bored the other day. So I decided to make a php calculator just out of the
    blue. I set it up and it works really good. You can see mine here . Ill give you guys the source
    code too if you want it. Here it is... Name this calculate_forum.html CODE <html>
    <head> <title>Calculation Form</title> </head> <body>
    <form method="post" action="calculate.php"> <p>Value 1:
    <input type="text" name="val1" size="10"></p> <p>....
  17. Tutorials
    (0)
    Hey everyone I got this site where you can find alot of tutorials on PHP
    http://www.w3schools.com/php/default.asp yOU CAN find other PROGRAMMING tutorials in this website
    2....http://www.w3schools.com/....
  18. Php Tutorials
    (6)
    Hey all, I'm new to the trap and these boards. I figured I would see what all I'm able to
    do here. There is one thing yall can help me with... Could you link me to a site that has excellent
    tutorials on learning to use PHP. I'm an experiance designer in HTML & CSS, but PHP is still
    quite new to me, so I would like to read up on it a bit before I attempt using it to construct a
    website. All referance and tutorial site links are welcome. I like having many options at hand. So,
    whatever you can provide will be great. Thanks in advance, J. (TS)....
  19. flatfile guestbook for wap sites
    (3)
    I dont know if any of you guys have a wapsite but i do so i made a guestbook. Here ....

    1. Looking for php, calculator, calculates, genetic, percentages, finding, sites, tutorials,

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for php, calculator, calculates, genetic, percentages, finding, sites, tutorials,

*MORE FROM TRAP17.COM*
advertisement



Php Calculator That Calculates Genetic Percentages? - I need help finding sites or tutorials.



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE