ITP100 Project Part 5: Designing A Class Named Grader ✓ Solved

ITP100 Project Part 5 Designing a class named grader

ITP100 Project: Part 5 Designing a class named grader.

Designing a class named grader. This class has no instance variables. Instead it has at least these five methods or functions: determines if a number is numeric and within a specific range; loads the values in an array and validates the number; determines what the minimum score is in a numeric array; calculates the sum of all values in a one-dimensional numeric array; determines the letter score based on a numeric value between 0 and 100. Modify your Part 3 solution by using the methods/functions in the grader class to determine the final letter grade you have to print to the file. All of the other requirements are the same as Part 4. Grader - + Grader() + LoadsArray(scores[]:Real Ref, size: Integer) + ValidateScore(score: Real, min:Real, max, Real): Real + MinimumScore(scores[]: Real, size: Integer): Real + SumArray(scores[]: Real, size: Integer): Real + LetterGrade(score: Real): String + CoronaGrade(score:Real): String First – create the class based on the class diagram Second – modify your Part 4 module to use this class.

Paper For Above Instructions

Designing a class named Grader involves creating various functions necessary for validating and calculating scores within a defined range. In this document, I will define the structure and methods of the Grader class and demonstrate how it can be utilized to compute a final letter grade.

Structure of the Grader Class

The Grader class does not contain instance variables as per the prompt. Instead, it consists of five primary methods that fulfill functional requirements:

  • Grader(): A constructor for the class, initializing any necessary setups if required.
  • LoadsArray(scores[]: Real Ref, size: Integer): This method loads the input scores into an array and performs validation on each score.
  • ValidateScore(score: Real, min: Real, max: Real): This method checks if the given score is numeric and falls within the specified range.
  • MinimumScore(scores[]: Real, size: Integer): This function determines the minimum score present in the provided array of scores.
  • SumArray(scores[]: Real, size: Integer): Calculates the sum of all values in a one-dimensional numeric array.
  • LetterGrade(score: Real): Converts a numeric score into a letter grade based on a standard grading scale.
  • CoronaGrade(score: Real): An extended method to check additional grading metrics if required.

Method Functionality

Each method is designed to be modular, allowing them to be called independently or within a sequence to achieve the program's goal of calculating a final grade, thus enhancing the reusability of the code.

1. ValidateScore Method

The ValidateScore method is crucial for ensuring integrity in data entry. It should return the score if valid or handle errors if invalid. The sample implementation could look like:

def ValidateScore(score, min, max):

if isinstance(score, (int, float)) and min

return score

else:

raise ValueError("Score must be numeric and within the given range.")

2. LoadsArray Method

This method would iterate through user inputs, validate them using ValidateScore, and populate the scores array accordingly. An example implementation is as follows:

def LoadsArray(scores, size):

for i in range(size):

score = input(f"Enter score {i + 1}: ")

scores[i] = ValidateScore(float(score), 0, 100)

3. MinimumScore Method

The MinimumScore method loops through the scores array to compute the lowest score, enhancing the statistical insight into the score distribution:

def MinimumScore(scores):

return min(scores)

4. SumArray Method

The SumArray method uses a simple summation algorithm to calculate the total score, critical for deriving average scores later:

def SumArray(scores):

return sum(scores)

5. LetterGrade Method

Finally, the LetterGrade method assigns letter grades based on specified thresholds:

def LetterGrade(score):

if score >= 90:

return "A"

elif score >= 80:

return "B"

elif score >= 70:

return "C"

elif score >= 60:

return "D"

else:

return "F"

Integration into Main Module

To utilize the Grader class in our main module, the existing code must be modified to create an instance of Grader and invoke its methods for calculating the final grade. This approach encapsulates the operations and ensures clarity in the flow of data.

Conclusion

The Grader class presents an organized and functional approach to managing score validation and grade calculations, promoting code readability and reducing the chance of errors while handling grade data. This structure ultimately facilitates a straightforward extension for future enhancements, aligning well with software design principles like object-oriented programming (OOP).

References

  • Beck, K. (2002). Extreme Programming Explained: Embrace Change. Addison-Wesley.
  • Deitel, P. J., & Deitel, H. M. (2012). C: How to Program (8th ed.). Pearson.
  • Horstmann, C. S., & Cornell, G. (2013). Core Java Volume I—Fundamentals (10th ed.). Prentice Hall.
  • Lewis, J. G. (2012). Fundamentals of Object-Oriented Programming in Java. Cengage Learning.
  • Lutz, M. (2013). Learning Python (5th ed.). O'Reilly Media.
  • McGrath, G. (2014). Object-Oriented Programming in Python. Cengage Learning.
  • Sharma, S. (2015). Learning to Program in C. O'Reilly Media.
  • Schildt, H. (2019). Java: The Complete Reference (11th ed.). McGraw-Hill.
  • Summerfield, M. (2010). Rapid GUI Programming with Python and Qt. Prentice Hall.
  • Tanenbaum, A. S., & Austin, T. (2012). Structured Computer Organization (5th ed.). Pearson Higher Ed.