Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

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

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

suggest a mechanism for this

Answered: 1 week ago