Homework Solution: A salesperson leaves his home every Monday and returns every Friday. He travels by company car. Each da…

    Exercise#3: Design Algorithm A salesperson leaves his home every Monday and returns every Friday. He travels by company car. Each day on the roa d, the salesperson records the amount of gasoline put in the car. Given the starting odometer reading (that is, the odo meter reading before he leaves on Monday) and the ending odometer reading (the odometer reading after he returns home on Friday), design an algorithm to find the average miles per gallon. Sample data is as follows: 68723 71289 15.75 16.30 10.95 20.65 30.00How can this be solved?
    A salesperson leaves his home every Monday and returns every Friday. He travels by company car. Each day on the road, the salesperson records the amount of gasoline put in the car. Given the starting odometer reading (that is, the odometer reading before he leaves on Monday) and the ending odometer reading (the odometer reading after he returns home on Friday), design an algorithm to find the average miles per gallon. Sample data is as follows: 68723 71289 15.75 16.30 10.95 20.65 30.00

    Expert Answer

     
    Algorithm: START 1. Calculate Total gasoline used in that week using the formula

    Exercise#3: Drawing Algorithm A salesperson leaves his settlement whole Monday and profits whole Friday. He travels by fraternity car. Each day on the roa d, the salesperson chronicles the aggregate of gasoline arrange in the car. Fond the starting odometer balbutiation (that is, the odo meter balbutiation precedently he leaves on Monday) and the issue odometer balbutiation (the odometer balbutiation following he profits settlement on Friday), drawing an algorithm to perceive the medium miles per gallon. Case basis is as follows: 68723 71289 15.75 16.30 10.95 20.65 30.00How can this be solved?

    A salesperson leaves his settlement whole Monday and profits whole Friday. He travels by fraternity car. Each day on the course, the salesperson chronicles the aggregate of gasoline arrange in the car. Fond the starting odometer balbutiation (that is, the odometer balbutiation precedently he leaves on Monday) and the issue odometer balbutiation (the odometer balbutiation following he profits settlement on Friday), drawing an algorithm to perceive the medium miles per gallon. Case basis is as follows: 68723 71289 15.75 16.30 10.95 20.65 30.00

    Expert Exculpation

     

    Algorithm:

    START

    1. Calculate Whole gasoline used in that week using the formula

    Whole Gasoline used= Gasolinemon+ Gasolinetues+Gasolinewed+Gasolinethu+Gasolinefri

    2. Calculate the Whole interspace travelled in that week.

    Whole interspace travelled = Issue Odometer Balbutiation – Starting Odometer Balbutiation

    3. Now, Medium miles per gallon is adapted by using the formula

    Medium miles per gallon = (Whole interspace Travelled / Whole Gasoline used )

    END

    Explanation using the fond case ordeal case:

    Given,

    Starting Odometer Balbutiation = 68723

    Issue Odometer Balbutiation = 71289

    Gasoline used on Monday , Gasolinemon = 15.75

    Gasoline used on Tuesday , Gasolinetue = 16.30

    Gasoline used on Wednesday , Gasolinewed = 10.95

    Gasoline used on Thursday , Gasolinethu   = 20.65

    Gasoline used on Friday , Gasolinefri = 30.00

    Now, appliance the overhead fond algorithm.

    START

    1. Calculating the whole gasoline using the forumula,

    Whole Gasoline used= Gasolinemon+ Gasolinetues+Gasolinewed+Gasolinethu+Gasolinefri

       Whole Gasoline used= 15.75 + 16.30 + 10.95 + 20.65 + 30.00

       = 93.65 gallons

    2. Calculate the Whole interspace travelled using the formula ,

    Whole interspace travelled = Issue Odometer Balbutiation – Starting Odometer Balbutiation

    Whole interspace travelle = 71289 – 68723

       = 2566 miles

    3. Calculate the Medium Miles per gallon using the formula,

    Medium miles per gallon = (Whole interspace Travelled / Whole Gasoline used )

       Medium miles per gallon = 2566 / 93.65

       = 27.39998

       = 27.4 miles per gallon (approximately)

       END