: " This is my homework and i couldn't do it,please help me. I wait your helpsss On the planet Zephod, which orbits the star Betelgeuse, the sharks increase at a rate of 5% of the guppy population per day, provided there are 50 or more guppies per shark. Otherwise, the sharks die off at a rate of 50% per day. The guppies increase at a rate of 80% per day, provided the shark population is less than 20 % of the guppy population. Otherwise there is no increase in the guppy population. Each shark eats 5 guppies a day. Write a C program that allows the user to input the initial shark population, the initial guppy population, and the number of days of observation is to cover. The program is to output a day-by-day account of the populations until one of them dies off or the end of the observation period is reached. All reproductions and deaths occur overnight. Any fractional fish are discarded. (These sharks only feed during the day.) Sample run: Please enter number of sharks: 54 Please enter number of guppies: 1000 Number of days to observe: 15 Start of day 1 sharks 54 guppies 1000 End of day 1 sharks 54 guppies 730 Start of day 2 sharks 27 guppies 1314 . . . " _commas () { _COMMAS=; _TH_SEP=,; c_num=$1 while : do case $c_num in ??? | ?? | ?) _COMMAS=${c_num}${_COMMAS:+"$_TH_SEP"$_COMMAS}; break ;; *) left=${c_num%???}; _COMMAS=${c_num#${left}}${_COMMAS:+"$_TH_SEP"$_COMMAS}; c_num=$left ;; esac; done; _COMMAS=${_COMMAS} } ## On the planet Zephod, which orbits the star Betelgeuse, ## the sharks increase at a rate of 5% of the guppy population per day, ## provided there are 50 or more guppies per shark. ## Otherwise, the sharks die off at a rate of 50% per day. shark_change() { if [ $(( $guppies / $sharks )) -ge 50 ] then shark_increase=$(( $guppies / 20 )) sharks=$(( $sharks + $shark_increase )) else sharks=$(( $sharks / 2 )) fi [ $sharks -le 0 ] && sharks=0 } ## The guppies increase at a rate of 80% per day, ## provided the shark population is less than 20 % of the guppy population. ## Otherwise there is no increase in the guppy population. guppy_increase() { if [ $(( $guppies / $sharks )) -ge 5 ] then guppy_plus=$(( ($guppies * 80 ) / 100 )) guppies=$(( $guppies + $guppy_plus )) fi [ $guppies -le 0 ] && guppies=0 } ## Each shark eats 5 guppies a day. guppy_gobble() { guppies_eaten=$(( $sharks * 5 )) guppies=$(( $guppies - $guppies_eaten )) [ $guppies -le 0 ] && guppies=0 } ## Write a C program that allows the user to input ## the initial shark population, ## the initial guppy population, ## and the number of days of observation is to cover. init() { printf "Please enter number of sharks: " read sharks printf "Please enter number of guppies: " read guppies printf "Number of days to observe: " read duration } print_it() { [ -z "$silent" ] && { _commas "$day"; day_c=$_COMMAS _commas "$sharks"; sharks_c=$_COMMAS _commas "$guppies"; guppies_c=$_COMMAS printf "%10s of day %${#duration}s %23s sharks %26s guppies\n" \ "$time" "$day_c" $sharks_c $guppies_c } } exit_test() { [ $sharks -le 0 ] || [ $guppies -le 0 ] && exit } case $1 in -b) sharks=${2:-54} guppies=${3:-1000} duration=${4:-15} ;; * ) init ;; esac # The program is to output a day-by-day account of the populations # until one of them dies off or the end of the observation period is # reached. # All reproductions and deaths occur overnight. # Any fractional fish are discarded. # These sharks only feed during the day. day=0 while [ $day -lt $duration ] do day=$(( $day + 1 )) time=Start print_it exit_test guppy_gobble time=End print_it exit_test guppy_increase shark_change done