Question: #include #include #include using namespace std; int main ( ) { / / Ask for the names of the competitors string names [ 3 ]

#include
#include
#include
using namespace std;
int main(){
// Ask for the names of the competitors
string names[3];
for (int i =0; i <3; i++){
cout << "Enter the name of competitor "<< i+1<<": ";
getline(cin, names[i]);
}
// Display menu and get user's choice
int choice;
cout <<"
Choose an event to enter results for:
";
cout <<"1. Farmers frame medley
";
cout <<"2. Axle deadlift
";
cout <<"3. Stone over bar
";
cout << "Enter 0 to quit.
";
cout << "Choice: ";
cin >> choice;
// Process the user's choice
switch (choice){
case 0:
cout << "Exiting program...
";
return 0;
case 1: {
// Farmers frame medley
double times[3];
for (int i =0; i <3; i++){
cout << "Enter the time (in seconds) for "<< names[i]<<": ";
cin >> times[i];
if (times[i]<0){
cout << "Invalid input, exiting program...
";
return 0;
}
}
// Determine rankings and points
int ranks[3]={1,2,3};
if (times[1]< times[0]) swap(ranks[0], ranks[1]);
if (times[2]< times[1]){
if (times[2]< times[0]) swap(ranks[0], ranks[2]);
else swap(ranks[1], ranks[2]);
}
int points[3]={3,2,1};
// Display results
cout <<"
Farmers frame medley results:
";
for (int i =0; i <3; i++){
int idx = ranks[i]-1;
cout << setw(10)<< names[idx]<<" completed in "<< fixed << setprecision(2)<< times[idx]<<" seconds. ";
if (i ==0) cout <<"1st place, "<< points[idx]<<" points.
";
else if (i ==1) cout <<"2nd place, "<< points[idx]<<" points.
";
else cout <<"3rd place, "<< points[idx]<<" points.
";
}
break;
}
case 2: {
// Axle deadlift
double weights[3];
for (int i =0; i <3; i++){
cout << "Enter the weight (in pounds) lifted by "<< names[i]<<": ";
cin >> weights[i];
if (weights[i]<0){
cout << "Invalid input, exiting program...
";
return 0;
}
}
// Determine rankings and points
int ranks[3]={1,2,3};
if (weights[1]> weights[0]) swap(ranks[0], ranks[1]);
if (weights[2]> weights[1]){
if (weights[2]> weights[0]) swap(ranks[0], ranks[2]);
else swap(ranks[1], ranks[2]);
}
int //NEEDS TO BE C++ WITH NO LOOPS OR VOIDS JUST A BASIC C++ CODE WITH LOTS OF COPY AND PASTE NO FUNCTIONS, IF ELSE AND CASES ONLY.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!