Question: This is a Pep/9 coding problem. I need to code the following problem in Pep/9 (I can convert from Pep/8 if that is easier) THE
This is a Pep/9 coding problem. I need to code the following problem in Pep/9 (I can convert from Pep/8 if that is easier)
THE ANSWER MUST BE IN PEP AND NOT IN ANY OTHER LANGUAGE
The goal is to take 10 user inputted scores, and to compare the total of the 10 to 3 different circumstances in which the student can pass. If it does not meet the criteria for any of those circumstances, the student fails.
If the sum of all 10 inputs is > 500, the student passes.
If the sum of all 10 inputs minus the lowest score is > 495, the student passes
If the sum of all 10 inputs minus the lowest score minus the second lowest score is > 480, the student passes.
Else the student fails.
I have written the proper code in C if that helps:
http://pastebin.com/5xKqfnTK
#include#include #define PASS1 500 #define PASS2 495 #define PASS3 480 int score; int low = 100; int secLow = 100; int total = 0; int i = 0; int main() { while ( i < 10) { //Loop user input 10 times printf("Score: "); //We are entering a test score here scanf("%d", &score); //Storing the test score in 'score' if (score < low) { //Checking if the input test 'score' is less than 'low' secLow = low; //If it is, set the current 'low' to 'secLow' low = score; //Then replace the current 'low' with 'score' } else if ( score < secLow ) { //If 'score' is not less than 'low', check if it is less than 'secLow' secLow = score; //If it is, replace 'secLow' with 'low' } total = total + score; //Every loop add 'score' to 'total' i++; //Every loop increment 'i' by 1 } /* **Below is pretty self explanatory. We are checking if the total is greater than 3 different scenarios that **Lead to the student passing. If none of those conditions are met, the student fails. */ if (total > PASS1) printf("Pass"); else if ( (total - low) > PASS2) printf("Pass"); else if ( (total - low - secLow) > PASS3) printf("Pass"); else printf("Fail"); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
