Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Must use the following functions bool menuChoice( int& event ) : this function prints the menu and gets the users event choice. It has

C++

Must use the following functions

bool menuChoice( int& event )

: this function prints the menu and gets the users event

choice. It has one parameter, the users event choice, that is passed by reference so that the actual

parameter is changed by the function. It prints an error mssage if the users event choice is not in the

range [0, ..., 3] and returns false. Otherwise, it returns true.

int calcNumLaps( int event )

: this function calculates and returns the number of laps for an

event. If the event number is invalid, it returns 0 for the number of laps.

void calcAndPrintResults( int numLaps, const string& firstName, const

string&lastName )

: this function calculates and prints all lap accelerations by getting lap times

from the user. It has three parameters: 1) the number of laps, 2) the skaters first name, and 3) the

skaters last name. It also prints the End of analysis message for the particular skater.

You MUST use the following

main

function. Read through it carefully.

int main() {

string fName, lName; // first and last name of skater

int event; // 1 = 500m, 2 = 1000m, 3 = 1500m

int numLaps; // number of laps in event

bool valid; // user entered valid event number?

// set precision, etc.

cout.precision( 2 );

cout.setf( ios::showpoint | ios::fixed );

cout << "Welcome to the Short Track Speed Analyzer! ";

do { // while user didn't say quit

valid = menuChoice(event);

if ( valid && event != QUIT ) { // valid event

// get skater name

cout << "Skater first and last name: ";

cin >> fName >> lName;

// calc number of laps in event

numLaps = calcNumLaps( event );

// calculate and print acceleration for all laps

calcAndPrintResults( numLaps, fName, lName );

} // end if valid event

} while ( event != QUIT );

cout << "Thank you for using the Short Track Speed Skating

<< " Analyzer! ";

return 0;

}

Sample execution

(using times from above video for Apolo Ohno)

Welcome to the Short Track Speed Skating Analyzer!

Please choose an event

1 500 meters

2 1000 meters

3 1500 meters

0 exit

Event: 1

Skater first and last name: Apolo Ohno

End time of lap 1 (in seconds): 6.65

Acceleration in m/s^2: 2.26

End time of lap 2 (in seconds): 15.83

Acceleration in m/s^2: -0.45

End time of lap 3 (in seconds): 24.6

Acceleration in m/s^2: 0.06

End time of lap 4 (in seconds): 33.14

Acceleration in m/s^2: 0.04

End time of lap 5 (in seconds): 41.93

Acceleration in m.s^2: -0.04

End of analysis for Apolo Ohno

Please choose an event

1 500 meter

2 1000 meter

3 1500 meter

0 exit

Event: 0

Thank you for using the Short Track Speed Skating Analyzer!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Does it exceed two pages in length?

Answered: 1 week ago

Question

Does it avoid typos and grammatical errors?

Answered: 1 week ago