• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: greater than AND less than
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: greater than AND less than


  • Subject: Re: greater than AND less than
  • From: Timothy Bates <email@hidden>
  • Date: Sun, 26 Aug 2001 21:11:56 +1000

On 8/26/01 6:38 PM, "Sean Malone" <email@hidden> wrote:
> I'm writing an application which averages grades for my students, based
> on the number of assignments and their respective weight in the syllabus so
> far so good. However, at the end, I'd like the script to return a letter
> grade based on the score.

> Boy, If THIS would only work:
> If finalAverage is greater than 92.65 or is less than 96.45 then...

the droid you are looking for is written

if ((finalAverage > 92.65) or (finalAverage < 96.45)) then beep

You can use the longhand 3greater than2, then key is building pairs of item
to compare: applescript cannot inuitively know that your second 3is2 refers
to finalAverage.

As to the larger solution, I have a similar system online served by apache,
but using php as a language, not applescript.

The relevant function in php is:

function webTestNumberToLetter($numericScore){
if ($numericScore <= 0) {
$letterGrade = "?" ;
} elseif ($numericScore <= 5) {
$letterGrade = "F";
} elseif ($numericScore <= 6) {
$letterGrade = "C-";
} elseif ($numericScore <= 7) {
$letterGrade = "C";
} elseif ($numericScore <= 8) {
$letterGrade = "C+";
} elseif ($numericScore <= 9) {
$letterGrade = "B-";
} elseif ($numericScore <= 10) {
$letterGrade = "B";
} else {
$letterGrade = "A";
}
return $letterGrade;
}

Converting this aPplesCript gives

on webTestNumberToLetter(numericScore)
if (numericScore > 0) then
set letterGrade to "?"
else if (numericScore > 5) then
set letterGrade to "F"
else if (numericScore > 6) then
set letterGrade to "C-"
else if (numericScore > 7) then
set letterGrade to "C"
else if (numericScore > 8) then
set letterGrade to "C+"
else if (numericScore > 9) then
set letterGrade to "B-"
else if (numericScore > 10) then
set letterGrade to "B"
else
set letterGrade to "A"
end if
return letterGrade
end webTestNumberToLetter

> If finalAverage is greater than or equal to 96.5 then set contents of,
> textbox "Computed Final Grade" to "A+"

> 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?

> One other question. After the grade is numerically averaged, I'd like
> the result to not exceed hundredths - 86.45 etc. I've looked at the round
> command, but that brings it up to an integer. How can the result be rounded
> to nearest hundredth?
>
> If you'd like to see the work in progress, there's a beta of this app I'm
> trying to finish at:
>
> http://darkwing.uoregon.edu/~spm29386/Software/index.html


References: 
 >greater than AND less than (From: Sean Malone <email@hidden>)

  • Prev by Date: Re: greater than AND less than
  • Next by Date: passion redux (or, read this before you download it)
  • Previous by thread: Re: greater than AND less than
  • Next by thread: Re: greater than AND less than
  • Index(es):
    • Date
    • Thread