Answer to Question #230504 in C++ for Praveen

Question #230504
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).
1
Expert's answer
2021-08-30T01:35:57-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS