Skip to content

W03 ‐ Arrays and Control structures (ASSESSED)

Atanbori edited this page Jan 16, 2025 · 2 revisions

CMP9133 - Workshop 3

University of Lincoln

School of Engineering and Physical Sciences

CMP9133 – Programming Principles

Landing page

Join the third workshop (the first assessed) at the dedicated LINK 💻

Task (assessed)

This task will help you practice working with arrays, variables, built-in data types, and control structures in C++. Moreover, it assesses the definition of a class, object instantiation, and how to manage data using objects.

Problem Statement

You are tasked with writing a C++ program to analyse the scores of a class of students. Your program should define a Student class to store individual student scores and then calculate and display various statistics based on the provided scores.

Instructions

  1. Define a class named Student with the following attributes:
    • An integer variable named score to store the student's score.
    • A constructor that takes an integer parameter and initializes the score attribute.
    • A method for setting the score of a student.
  2. Calculate and display the following statistics:
    • The average score of the students.
    • The highest score achieved by a student.
    • The lowest score achieved by a student.
    • The number of students who scored above the average.
    • The number of students who scored below the average.

NB: You don't need to worry about instantiating and initialising objects of class Student, that is done within the test script as in the following image. Please do not create a main() function in the file you should edit. 374258790-be6553d6-46d9-4863-b255-564c22752c95

Note: You should use appropriate control structures (loops, conditionals) and class methods to implement the required functionality.

Clone this wiki locally