C++ code that accept the names and finish times of 3 racers, and will determine
ID: 3638653 • Letter: C
Question
C++ code that accept the names and finish times of 3 racers, and will determine and display their finish order. You may assume that there are no ties, i.e. no one has a duplicate finish time.
Here is a sample run (user input shown in bold):
What is the first runner's name: Rabbit
What was Rabbit's time, in seconds: 17
What is the second runner's name: Turtle
What was Turtle's time, in seconds: 15
What is the third runner's name: Roadrunner
What was Roadrunner's time, in seconds: 16
1st place: Turtle
2nd place: Roadrunner
3nd place: Rabbit
Explanation / Answer
#include #include using namespace std; int maxOfThreeNumbers(int a, int b, int c) { if (a > b) { if (a > c) { return a; } else { return c; } } else { if (b > c) { return b; } else { return c; } } } int maxOfTwoNumbers(int a, int b) { if (a > b) { return a; } else { return b; } } int main() { string a, b, c; int a1, b1, c1; int first, second; printf("What is the first runner's name: "); getline(cin, a); coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.