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

In-class Activity We want to create a racetimes application to assist racers (e.

ID: 3742662 • Letter: I

Question

In-class Activity We want to create a racetimes application to assist racers (e.g., running, spec iwalking, cars, motorcycles) in analyzing their performance. M ny races have different parts (e.g., terrain, turns, rally poini), and we want to keep track of the distance and time of each segment. We would like to create a program that will analyze the distances and times to help the racer analyze their performance. Determine the types of data we need to store, define the structs and variables and think of possible operations to perforn

Explanation / Answer


#include <iostream>

using namespace std;
struct racer
{
int racer_id;
string name;
char raceType; // C - car , R - running, B -bike , W- Speed walking
string Terrain; // rock, desert, mountain
int turns;
int rallypoint;
float racetime;
float distance;
};
int main()
{
racer r;
// accept values
cout<<" Enter Racer Id ";
cin>>r.racer_id;
cout<<" Enter Racer Name ";
cin>>r.name;
cout<<" Enter Race Type (C - car , R - running, B -bike , W- Speed walking) ";
cin>>r.raceType;
cout<<" Enter Terrain :: ";
cout<<" 1. Rock 2. Desert 3. Mountain "<<endl;
cin>>r.Terrain;
do
{
cout<<" Enter Number of turns (1 -5) ";
cin>>r.turns;
}while(r.turns==0 || r.turns>5);
do
{
cout<<" Enter Rally Point ";
cout<<" 1. Point 1 2. Point 2 3. Point 3"<<endl;
cin>>r.rallypoint;
}while(r.rallypoint>3 || r.rallypoint<1);
cout<<" Enter Race Time(min) ";
cin>>r.racetime;
cout<<" Enter Race distance(Km) ";
cin>>r.distance;
// display Statistics
cout<<" ************Racer Statistics**************";
cout<<" Name :: "<<r.name;
if(r.raceType=='C')
cout<<" Race Type :: Car";
else if(r.raceType=='R')
cout<<" Race Type :: Running";
else if(r.raceType=='B')
cout<<" Race Type :: Bike";
else
cout<<" Race Type :: Speed Walking";
  
if(r.Terrain=="1")
cout<<" Terrain :: Rocks";
else if(r.Terrain=="2")
cout<<" Terrain :: Desert";
else
cout<<" Terrain :: Mountain";
  
cout<<" Number of turns :: "<<r.turns;
cout<<" Rally Point :: "<<r.rallypoint;
cout<<" Distance covered in race :: "<<r.distance;
cout<<" Time taken in race :: "<<r.racetime;
cout<<" Speed(Km/Hr) :: "<<r.distance/(r.racetime/60);
return 0;
}