Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ header file that will allow race judges to manage and then award points to r

ID: 3568103 • Letter: C

Question

C++ header file that will allow race judges to manage and then award points to runners according to their finishing position. It provides services needed to manage a race under the "OPEN RACE" standard adopted by the Humans United for Racing Limited. (HURL) - see formal standard labeled: (HURL-OR_ icuducme_ver_1.3.X). USER SERVICES(INTERRFACE):The following are methods that can be used as part of the AWARDER class Constructors: - AWARDER : will setup a complete race environment but with Zero (0) capacity. - AWARDER(int) : sets the limit of number of runners allowed to finish Methods: - setMultiplier(int) : sets the multiplier to be used for awarding points - openRace( ) : open the race to allow adding of runners - closeRace( ) : close the race to stop anymore runners recorded at finish - addRunner( ) : record that a runner has begun the race - recordFinish(int) : a 1-4 digit id for each runner (assumes unique) - computePoints( ) : compute the points before awarding - awardPoints( ) : award the points for the race report generated Example Race Outline: AWARDER judge(50); // set up race to handle up to 50 runners judge.setMultiplier(10); // set the award multiplier judge.openRace( ); // begin allowing runners to enter the race judge.addRunner( ); // a runner registers and begins running judge.addRunner( ); // a runner registers and begins running judge.recordFinish(135); // record that runner with id 135 has finished the race // runners can be added and can finish at any time the race is open. Judge.addRunner() // another runner has started the race. // race is being run with more runners being added/finishing over time judge.closeRace( ); // end the recording of runners finishing the race judge.computePoints( ); // computes the points for each runner judge.awardPoints( ); // display user pos, id, and pts from 1st to .. Attributes: multiplier : multiplier value used in the awarding of points runnerCount : number of runners in the race raceOpen : status of the race (true = race is open) finish : a stack of racers that have finished the race. Pushed as they finish award : id of runners who have finished (1st place on top) points : award values for runners. (1st place on top of stack) Constructors: AWARDER (void) : Sets up race and the number of allowed finished runners to zero (0) AWARDER (in size : int) : Sets up race and sets the limit of allowed finished runners to size Methods: addRunner(void) : record a new runner in the race recordFinish(in id : int) : record when runner with id finishes the race endRace(void) : close the race (no more runners recorded as finished openRace(void) : start the race (allow runners to register and run) setMultiplier(in m : int) : set the multiplier value used to scale the reward points computePoints( void ) : compute the points for each finished runner awardPoints(void) : display the id and award points from 1st to Award Point Formula (HURL-OR_ icuducme_ver_1.3.X) Award Points = ( TOTAL-FINISHED-RUNNERS X SCALING-MULTIPLIER ) / RUNNERS-FINISH-PLACE Standard default value of the Scaling-Multiplier is 1. Assumptions: id : the runner id is limited up to a four (4) digit integer value. size : the size of the race (max number of runners allowed to finish) is limited by the implementations definition of MAXINT. It is assumed race sizes will be below this limit.

Explanation / Answer

// Includes
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

// Main Function
int main()
{
   string name1 , name2 , name3;
   float time1 , time2 , time3;
   double first , second , third;

   cout << "This displays who came 1st , 2nd, 3rd. ";

   cout << "Enter name1: ";
   getline(cin , name1);
   cout << "Enter name2: ";
   getline(cin , name2);
   cout << "Enter name3: ";
   getline(cin , name3);
   cout << "Enter time1: ";
   cin >> time1;
   cout << "Enter time2: ";
   cin >> time2;
   cout << "Enter time3: ";
   cin >> time3;

   while (time1 < 0 || time2 < 0 || time3 < 0)
   {
       cout << " The times must be greater than 0. ";
       cout << "Enter name1: ";
       getline(cin , name1);
       cout << "Enter name2: ";
       getline(cin , name2);
       cout << "Enter name3: ";
       getline(cin , name3);
       cout << "Enter time1: ";
       cin >> time1;
       cout << "Enter time2: ";
       cin >> time2;
       cout << "Enter time3: ";
       cin >> time3;
   }

   cout.setf(ios_base::fixed , ios_base::floatfield);
   cout.precision(1);

   cout << " ";

   if (time1 < time2 && time1 < time3)
   {
       first = time1;
       cout << first << endl;
       cout << name1 << " came in 1st with a time of " << first << endl;
   }
   else if (time2 < time1 && time2 < time3)
   {
       first = time2;
       cout << name2 << " came in 1st with a time of " << first << endl;
   }
   else if (time3 < time1 && time3 < time2)
   {
       first = time3;
       cout << name3 << " came in 1st with a time of " << first << endl;
   }

   if (time1 < time3 && time1 > time3)
   {
       second = time1;
       cout << name1 << " came in 2nd with a time of " << second << endl;
   }
   else if (time2 < time3 && time2 > time1)
   {
       second = time2;
       cout << name2 << " came in 2nd with a time of " << second << endl;
   }
   else if (time3 < time2 && time3 > time1)
   {
       second = time3;
       cout << name3 << " came in 2nd with a time of " << second << endl;
   }

   if (time1 > time2 && time1 > time3)
   {
       third = time1;
       cout << name1 << " came in 3rd with a time of " << third << endl;
   }
   else if (time2 > time1 && time2 > time3)
   {
       third = time2;
       cout << name2 << " came in 3rd with a time of " << third << endl;
   }
   else if (time3 > time1 && time3 > time2)
   {
       third = time3;
       cout << name3 << " came in 3rd with a time of " << third << endl;
   }
  
   cout << endl << "Press ENTER to exit...";
   cin.clear();
   cin.sync();
   cin.get();

   return 0;
}
Edit & Run

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote