Re: greater than AND less than
Re: greater than AND less than
- Subject: Re: greater than AND less than
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 26 Aug 2001 03:57:57 -0700
On 8/26/01 1:38 AM, "Sean Malone" <email@hidden> wrote:
>
After this the trouble starts. Here are the ranges for the grades:
>
>
{{96.5, 100}, {92.5, 96.45}, {89.5, 92.45}, {86.5, 89.45}, {82.5, 86.45},
>
{79.5, 82.45}, {76.5, 79.45}, {72.5, 76.45}, {69.5, 72.45}, {64.5, 69.45},
>
{0, 64.45}}
>
>
I've pulled my hair out trying to figure out how to compare the
>
"finalAverage" to a range of scores. I've tried setting up a range using
>
things like:
>
>
(Reals from 92.5 to 96.45)
>
>
But this always returns that it "can't get reals.....etc."
>
>
So, does anyone know how I can get the script to return grades {"A+", "A",
>
"A-", "B+", "B", "B-", "C+", "C", "C-", "D", "F"} based on the ranges above?
>
>
Boy, If THIS would only work:
>
>
----------------
>
>
If finalAverage is greater than 92.65 or is less than 96.45 then...
>
>
----------------
if finalAverage is greater than 92.65 AND is less than 96.45 then
will do exactly what you want. You need a grade within that range to fulfill
BOTYH conditions, not just one or the other of them. (Actually, you'd better
say "... is less than or equal to 96.45", or that grade will be skipped
completely. and the same for :more than or equal to" to catch 0.) You don't
need to define the data type (real) in AppleScript: it's implicit when
you're dealing with numbers and say "less than" or "greater than".
------------
set finalAverage to 85.7662 -- for example
set finalAverage to ((100 * (finalAverage + 0.005)) div 1) / 100
set gradeRangeList to {{96.5, 100}, {92.5, 96.45}, {89.5, 92.45}, {86.5,
89.45}, {82.5, 86.45}, {79.5, 82.45}, {76.5, 79.45}, {72.5, 76.45}, {69.5,
72.45}, {64.5, 69.45}, {0, 64.45}}
set gradeList to {"A+", "A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D",
"F"}
repeat with i from 1 to 11
set gradeRange to item i of gradeRangeList
if finalAverage is greater than or equal to item 1 of gradeRange and
finalAverage is less than or equal to item 2 of gradeRange then
set theGrade to item i of gradeList
exit repeat
end if
end repeat
{finalAverage, theGrade}
--> {85.77, "B"}
--
Paul Berkowitz