CSCI 240 Fall 2025

Assignment 8
Classes
(100 points)


Due: Tuesday, November 25 on the autograder and Blackboard by 11:59 PM

For this assignment, implement methods for a class called PowerLifter that will represent a single powerlifter.

int main() has been provided for this assignment.

The cpp file that is submitted for grading must be named assign8.cpp.

The PowerLifter class

The PowerLifter class declaration should be placed at the top of a source code file while the method implementations should be placed after the closing curly brace for main().

Data Members

The PowerLifter class contains six private data members.

Constructor

The default constructor (i.e. one that takes no arguments) should create a "No Name" powerlifter with a Wilks Coefficient of 1.0, and -1 for all their max lifts.

Public Methods

The following methods are required for the PowerLifter class. They should all be public.

void setFirst(string newFirst)

void setLast(string newLast[)

void setCoef(float newCoef)

These methods will simply copy the argument value to the corresponding data member.

The only constraint to implement is to ensure the coefficient data member is only changed when the passed in argument value is not a negative value and not a value greater than 2.0.

void setSquat(int newSquat)

This method will update the data member representing the max squat value for the powerlifter.

It takes one argument: an integer that holds the potential new max squat value. It returns nothing.

The data member representing the max squat value should only be updated if the passed in value is greater than -1.

void setBench(int newBench)

void setDeadlift(int newDeadlift)

These methods follow the same concepts as the setSquat method but work with the data members that represent the max bench value and max deadlift value, respectively.

int getTotal()

This method simply returns the sum of the three integer data members. That is: the squat, bench, and deadlift.

int wilksScore()

This method will return the integer typecast of their Wilks Score, which by default will be a float value.

A powerlifter's Wilks Score is calculated by multiplying their powerlifting total (i.e. the value returned by the method described above) by their Wilks Coefficient.

For example, a powerlifter with a total equal to 2000 lbs and a Wilks Coefficient equal to 0.6 would have a Wilks Score of:

Wilks Score = (2000 * 0.6)
Wilks Score = 1200

void display()

This method will display a formatted PowerLifter object.

It takes no arguments and returns nothing.

Display values in the following order: first name, last name, coefficient, maximum squat values, maximum bench value, maximum deadlift value, total value, and Wilks score.

The two name data members should be displayed left justified in fields that are 18 characters. The numeric data members, the PowerLifter's total, and the PowerLifter's Wilks Score should be displayed right justified in fields that are 10 characters. The PowerLifter's Wilks coefficient should be displayed with exactly 4 digits after the decimal point.

Make sure to end with a new line character.

Input File

The data for this program will be read from an input file. There are multiple files available that can be found on Blackboard with the assignment write-up and here:

lifters1.txt

lifters2.txt

lifters3.txt

lifters4.txt

The files consist of a set of records for varioushe lifters. Each record represents a single lifter and contains: the first name, the last name, Wilks Coefficient, squat value, bench value, and deadlift value. A record in the file resembles the following:

Daniel	Rogness	0.5986	475	345	475

Note: It is okay to assume that if there is a first name in a record, there will be a last name, coefficient, squat value, bench value, and deadlift value.

Refer back to assignment 7 if a reminder is needed about how to work with an input file: Assignment 7 write-up

main()

int main() has been written for this assignment. All that is required is to add the class definition and methods.

Assignment 8 driver program

Programming Requirements

  1. The constructor and methods MUST have a documentation box like the ones from the previous assignments.

  2. Hand in a copy of the source code (the CPP file) from Part 2 of the assignment on the autograder and Blackboard.

Output

Input file name? lifters2.txt

The input file is lifters2.txt

Daniel            Rogness               0.5986       475       345       475      1295       775
Jessica           Buettner              0.9429       484       237       546      1267      1194
Amanda            Lawrence              0.8917       564       287       573      1424      1269
Megan             Gallagher             1.0740       309       171       408       888       953