Logic problem

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Logic problem

Post by doctorized »

I am making an app that stores and manages school grades. There are classes that have numbers up to 10 as grades, such as 10, 9, 8 etc and classes that have letters as grades, such as A, B, C. I am trying to write a code to calculate the averages. I can calculate the averages for the numbers but I am having hard time finding the logic behind the averages for letters. Nobody knows how many letters are there that take part in the calculation process as a student may be examined 10 or 15 or 20 or even more times. I tried to replace letters with numbers, such as A with 10 and B with 8.5 (A covers 9 and 10, B covers 7 and 8), and turn the average number to letter with something like that:

Code: Select all

If grade >=8.5
   Result ="A" 
Elseif grade >= 6.5
   Result = "B" 
EndIf
but the result is wrong. For example, let's say that we have one A and two B. The logic says the result is B. The above code returns A. Any ideas?
User avatar
STARGÅTE
Addict
Addict
Posts: 2063
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Logic problem

Post by STARGÅTE »

doctorized wrote: Sun Oct 17, 2021 11:18 am I tried to replace letters with numbers, such as A with 10 and B with 8.5 (A covers 9 and 10, B covers 7 and 8 ), and turn the average number to letter with something like that:
If A covers 9 and 10 and B covers 7 and 8, than A = 9.5 and B = 7.5.

If you then have A, B, B --> 9.5+7.5+7.5 = 24.5 --> /3 = 8.17 = B
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: Logic problem

Post by doctorized »

STARGÅTE wrote: Sun Oct 17, 2021 11:28 am If A covers 9 and 10 and B covers 7 and 8, than A = 9.5 and B = 7.5.
This seems to solve the problem! Thank you very much!
Post Reply