Re: NEWBIE: Code, C question. [Part 2] (fwd)

From: Steve Wilson (swilson@WHC.NET)
Date: 05/13/96


Billy H. Chan wrote:
> 
> From: Fionn Colvin <fcolvin@metz.une.edu.au>
> 
>        Ok, I changed my percent line to:
> 
>        percent = (100 * current) / total
> 

Also suggest eliminating static "word", all those strcpy's
aren't needed, plus they take up space.  Try the following
rewrite of see_good.

Later Days,
Steve Wilson
<swilson@whc.net>  

char *see_good(int current, int total)
{
  int percent;

  if ((total == 200) && (current < 0))
    current = 100 - current;

  if (total < 1)
    total = 1;

  percent = (current * 100) / total;

  if (percent < 1)
    percent = 1;

  if (percent >= 100)
    return "supreme";
  else if (percent >= 90)
    return "excellent";
  else if (percent >= 80)
    return "very good";
  else if (percent >= 70)
    return "good";
  else if (percent >= 60)
    return "above average";
  else if (percent >= 50)
    return "average";
  else if (percent >= 40)
    return "below average";
  else if (percent >= 30)
    return "fair";
  else if (percent >= 20)
    return "poor";
  else if (percent >= 10)
    return "bad";
  else
    return "pathetic";
}



This archive was generated by hypermail 2b30 : 12/18/00 PST