|
| 1 | +/* You and your friends Tom, Jane, Peter and John got their final exam results. Your total |
| 2 | +score is 85, Tom’s total score is 66, Jane’s total score is 95, Peter’s total score is 56 |
| 3 | +and John’s total score is 40. The grading chart is |
| 4 | +80 or above A grade |
| 5 | +60 or above B grade |
| 6 | +50 or above C grade |
| 7 | +40 or above D grade |
| 8 | +39 or less => F grade |
| 9 | +
|
| 10 | +Write a program to find your and your friends’ grades using if-else. |
| 11 | +
|
| 12 | +
|
| 13 | +
|
| 14 | +[View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) */ |
| 15 | + |
| 16 | + |
| 17 | +var myResult = 85; |
| 18 | +var tomsResult = 66; |
| 19 | +var janesResult = 95; |
| 20 | +var petersResult = 56; |
| 21 | +var johnsResult = 40; |
| 22 | + |
| 23 | + |
| 24 | +/* --------------------------------------------------------------------------- |
| 25 | + Program for finding my and my friends’ grades using if-else. |
| 26 | +-------------------------------------------------------------------------- */ |
| 27 | + |
| 28 | + |
| 29 | +/* ----------------------------- |
| 30 | + For my result |
| 31 | +--------------------------------- */ |
| 32 | + |
| 33 | +if( myResult <= 39){ |
| 34 | + console.log("Sorry !! Shourav😞😥 you failed in the exam. You got " + myResult + " out of 100. So your Grad is 'F' ") ; |
| 35 | +} |
| 36 | + |
| 37 | +else if( 40 <= myResult && myResult < 50 ){ |
| 38 | + console.log("Congratulations Shourav🥳💐💐 !! you passed the exam. You got " + myResult + " out of 100. So your Grad is 'D' ") ; |
| 39 | +} |
| 40 | + |
| 41 | +else if( 50 <= myResult && myResult < 60 ){ |
| 42 | + console.log("Congratulations Shourav🥳💐💐 !! you passed the exam. You got " + myResult + " out of 100. So your Grad is 'C' ") ; |
| 43 | +} |
| 44 | + |
| 45 | +else if( 60 <= myResult && myResult < 80 ){ |
| 46 | + console.log("Congratulations Shourav🥳💐💐 !! you passed the exam. You got " + myResult + " out of 100. So your Grad is 'B' ") ; |
| 47 | +} |
| 48 | + |
| 49 | +else { |
| 50 | + console.log("Congratulations Shourav, It's Awesome🥳💖💕 !! you are the Best. You got " + myResult + " out of 100. So your Grad is 'A' ") ; |
| 51 | +} |
| 52 | + |
| 53 | + |
| 54 | +/* ----------------------------- |
| 55 | + For Tom's Result |
| 56 | +--------------------------------- */ |
| 57 | + |
| 58 | +if( tomsResult <= 39){ |
| 59 | + console.log("Sorry !! Tom😞😥 you failed in the exam. You got " + tomsResult + " out of 100. So your Grad is 'F' ") ; |
| 60 | +} |
| 61 | + |
| 62 | +else if( 40 <= tomsResult && tomsResult < 50 ){ |
| 63 | + console.log("Congratulations tom🥳💐💐 !! you passed the exam. You got " + tomsResult + " out of 100. So your Grad is 'D' ") ; |
| 64 | +} |
| 65 | + |
| 66 | +else if( 50 <= tomsResult && tomsResult < 60 ){ |
| 67 | + console.log("Congratulations Tom🥳💐💐 !! you passed the exam. You got " + tomsResult + " out of 100. So your Grad is 'C' ") ; |
| 68 | +} |
| 69 | + |
| 70 | +else if( 60 <= tomsResult && tomsResult < 80 ){ |
| 71 | + console.log("Congratulations Tom🥳💐💐 !! you passed the exam. You got " + tomsResult + " out of 100. So your Grad is 'B' ") ; |
| 72 | +} |
| 73 | + |
| 74 | +else { |
| 75 | + console.log("Congratulations Tom, It's Awesome🥳💖💕 !! you are the Best. You got " + tomsResult + " out of 100. So your Grad is 'A' ") ; |
| 76 | +} |
| 77 | + |
| 78 | + |
| 79 | +/* ----------------------------- |
| 80 | + For Jane's Result |
| 81 | +--------------------------------- */ |
| 82 | + |
| 83 | +if( janesResult <= 39){ |
| 84 | + console.log("Sorry !! Jane😞😥 you failed in the exam. You got " + janesResult + " out of 100. So your Grad is 'F' ") ; |
| 85 | +} |
| 86 | + |
| 87 | +else if( 40 <= janesResult && janesResult < 50 ){ |
| 88 | + console.log("Congratulations Jane🥳💐💐 !! you passed the exam. You got " + janesResult + " out of 100. So your Grad is 'D' ") ; |
| 89 | +} |
| 90 | + |
| 91 | +else if( 50 <= janesResult && janesResult < 60 ){ |
| 92 | + console.log("Congratulations Jane🥳💐💐 !! you passed the exam. You got " + janesResult + " out of 100. So your Grad is 'C' ") ; |
| 93 | +} |
| 94 | + |
| 95 | +else if( 60 <= janesResult && janesResult < 80 ){ |
| 96 | + console.log("Congratulations Jane🥳💐💐 !! you passed the exam. You got " + janesResult + " out of 100. So your Grad is 'B' ") ; |
| 97 | +} |
| 98 | + |
| 99 | +else { |
| 100 | + console.log("Congratulations Jane, It's Awesome🥳💖💕 !! you are the Best. You got " + janesResult + " out of 100. So your Grad is 'A' ") ; |
| 101 | +} |
| 102 | + |
| 103 | +/* ----------------------------- |
| 104 | + For Peter's Result |
| 105 | +--------------------------------- */ |
| 106 | + |
| 107 | +if( petersResult <= 39){ |
| 108 | + console.log("Sorry !! Peter😞😥 you failed in the exam. You got " + petersResult + " out of 100. So your Grad is 'F' ") ; |
| 109 | +} |
| 110 | + |
| 111 | +else if( 40 <= petersResult && petersResult < 50 ){ |
| 112 | + console.log("Congratulations Peter🥳💐💐 !! you passed the exam. You got " + petersResult + " out of 100. So your Grad is 'D' ") ; |
| 113 | +} |
| 114 | + |
| 115 | +else if( 50 <= petersResult && petersResult < 60 ){ |
| 116 | + console.log("Congratulations Peter🥳💐💐 !! you passed the exam. You got " + petersResult + " out of 100. So your Grad is 'C' ") ; |
| 117 | +} |
| 118 | + |
| 119 | +else if( 60 <= petersResult && petersResult < 80 ){ |
| 120 | + console.log("Congratulations Peter🥳💐💐 !! you passed the exam. You got " + petersResult + " out of 100. So your Grad is 'B' ") ; |
| 121 | +} |
| 122 | + |
| 123 | +else { |
| 124 | + console.log("Congratulations Peter, It's Awesome🥳💖💕 !! you are the Best. You got " + petersResult + " out of 100. So your Grad is 'A' ") ; |
| 125 | +} |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | +/* ----------------------------- |
| 130 | + For John's Result |
| 131 | +--------------------------------- */ |
| 132 | + |
| 133 | +if( johnsResult <= 39){ |
| 134 | + console.log("Sorry !! Johns😞😥 you failed in the exam. You got " + johnsResult + " out of 100. So your Grad is 'F' ") ; |
| 135 | +} |
| 136 | + |
| 137 | +else if( 40 <= johnsResult && johnsResult < 50 ){ |
| 138 | + console.log("Congratulations Johns🥳💐💐 !! you passed the exam. You got " + johnsResult + " out of 100. So your Grad is 'D' ") ; |
| 139 | +} |
| 140 | + |
| 141 | +else if( 50 <= johnsResult && johnsResult < 60 ){ |
| 142 | + console.log("Congratulations John🥳💐💐 !! you passed the exam. You got " + johnsResult + " out of 100. So your Grad is 'C' ") ; |
| 143 | +} |
| 144 | + |
| 145 | +else if( 60 <= johnsResult && johnsResult < 80 ){ |
| 146 | + console.log("Congratulations John🥳💐💐 !! you passed the exam. You got " + johnsResult + " out of 100. So your Grad is 'B' ") ; |
| 147 | +} |
| 148 | + |
| 149 | +else { |
| 150 | + console.log("Congratulations John, It's Awesome🥳💖💕 !! you are the Best. You got " + johnsResult + " out of 100. So your Grad is 'A' ") ; |
| 151 | +} |
| 152 | + |
| 153 | + |
0 commit comments