Perl solution, using a regex to extract the last digit (but we need to replace 100 by 99 for it to work).
#!/usr/bin/perlusewarnings;usestrict;useList::Utilqw{ sum };sub grade{my$mean=int(sum(@_)/@_);return'F'if$mean<60;$mean=99if$mean==100;my$sign=($mean=~/(.)$/)[0]<5?'-':'+';returnqw( D C B A )[($mean-60)/10].$sign}useTest::Moretests=>6;isgrade(100,100,100)=>'A+';isgrade(60,60,60)=>'D-';isgrade(64,55,92)=>'C-';isgrade(99,89,93)=>'A-';isgrade(33,99,95)=>'C+';isgrade(60,60,59)=>'F';
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Perl solution, using a regex to extract the last digit (but we need to replace 100 by 99 for it to work).