Description
You are working on an app for a company like Uber. You will be provided with the number of laps that the user has
taken and travel details (distance, speed and direction) of the laps. Write a program that calculates the total duration of
the trip and also the direction in which the customer has travelled.
Input:
First line of the input will be the number of laps.
The rest of the lines in the input will contain entry in the format of "Distance Speed Direction" for each lap.
Output:
T. First line of the output should show the total duration of the trip in minutes (T).
2. Second line of the output should show the direction from the starting point (D).
#include <iostream>
#include <string>
using ​namespace std;
float timeTaken(float dist, float sp, int totalLaps){
  return (dist /sp ) * totalLaps;
}
int main(){
  int NumberOfLaps;
  float distanceOfOneLap, speed;
  string directionOfOneLap;
  cout<<"Enter the total of laps: ";
  cin>>NumberOfLaps;
  cout<<"Enter the distance of one lap: ";
  cin>>distanceOfOneLap;
  cout<<"Enter the speed of one lap: ";
  cin>>speed;
  cout<<"Enter the direction. It must N, E, W, or S: ";
  cin>>directionOfOneLap;
  cout<<"\nTime Taken: "<<timeTaken(distanceOfOneLap, speed, NumberOfLaps)<<endl;
  cout<<"Direction: "<<directionOfOneLap<<endl;
  return 0;
}
Comments
Leave a comment