Description
You are working on an app for a company like Uber You will be provided with the number of taps 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
1. 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,
1 First line of the output should show the total distance of the trip in meter. 2. Second line of the output should show the direction from the starting point (D)
Constraints
1. Possible values of input direction are N. E. WS N.E.W.S
M. North
East
W West
South
2. Possible values of output direction are (N. EWS NE. NW, SE SW)
N-North
E-East
w West
5-South
NE North East
NW North West
SE South East
Sw South West
3.00 KM Distance 999999KM
#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