fork download
  1. public class StudentResultNotes {
  2. public static void mainMethod() {
  3.  
  4. // Subject marks
  5. Integer English = 65;
  6. Integer Hindi = 55;
  7. Integer Maths = 70;
  8. Integer Physics = 60;
  9. Integer Chemistry = 50;
  10.  
  11. // Calculate total
  12. Integer totalmarks = English + Hindi + Maths + Physics + Chemistry;
  13. System.debug('Total Marks = ' + totalmarks);
  14.  
  15. // Calculate average
  16. Decimal Averagemarks = totalmarks / 5;
  17. System.debug('Average Marks = ' + Averagemarks);
  18.  
  19. // Check Pass / Fail
  20. if(English >= 40 && Hindi >= 40 && Maths >= 40 && Physics >= 40 && Chemistry >= 40) {
  21. System.debug('Student Result = PASS');
  22.  
  23. // Grade calculation
  24. if(Averagemarks >= 60) {
  25. System.debug('Your Grade is : A');
  26. }
  27. else if(Averagemarks >= 50 && Averagemarks <= 59) {
  28. System.debug('Your Grade is : B');
  29. }
  30. else if(Averagemarks >= 40 && Averagemarks <= 49) {
  31. System.debug('Your Grade is : C');
  32. }
  33. }
  34. else {
  35. System.debug('Student Result = FAIL');
  36. }
  37. }
  38. }
  39.  
Success #stdin #stdout #stderr 0.02s 8912KB
stdin
Standard input is empty
stdout
Object: UndefinedObject error: did not understand #StudentResultNotes
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject class(Object)>>doesNotUnderstand: #StudentResultNotes (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
stderr
./prog:2: parse error, expected '}'