Answer to Question #273564 in Electrical Engineering for NAVINKUMAR

Question #273564

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

1
Expert's answer
2021-12-01T06:29:01-0500

#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