Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Starter stub tripStarter.c FUNCTIONS ASSIGNMENT Design and implement an interact

ID: 3602649 • Letter: S

Question

Starter stub tripStarter.c

FUNCTIONS ASSIGNMENT

Design and implement an interactive program named trip.c that collects information about the user's car and planned travel, and reports back useful information.

The dialog below shows exactly what data should be collected as input and reported as output.

Some Hints to get started

/* Not tested not complete code

   Just to get you started

*/

#include <stdio.h>

     /* FUNCTION PROTOTYES */

      void WelcomeMessage();

     void AskUserForInput(); /* ask and check whether user wants to continue

                                                 if wants to continue gather information

                                                and calculate the results (optional create more functions)

                                             */

     void PrintTripSummary(float fuel, float minCost, float maxCost, float travelMiles);

                                           /* could call this from AskUserForInput();

                                                 In a loop and feed it the user input

                                            */

    /* MAIN */

     int main() {

        /* Call the functions */

         return 0;

}

You do not need to verify user input data. Presume that the user enters reasonable/correct data.

Although you might want to test the results of entering "interesting data" such as alpha data instead of numeric.

Below is the program output.  Blue is used to illustrate the output, while regular text shows user Input.

Welcome to the Trip Planner!

So you are ready to take a trip? Let me help you plan for

your fuels costs and required stops to fill up your tank.

============================================================

Please provide answers to the prompts below and I will

display a summary for you when I have computed the results.

============================================================

Please input your car's average miles per gallon (enter 0 to quit) >> 21

Please tell me the range of fuel costs you expect to pay (per gallon).

The lowest per gallon cost of fuel is >> 2.50

The highest per gallon cost of fuel is >> 3.50

Please tell me how many miles you plan to travel >> 1000

===============   Trip Summary   ==================

You will need to purchase 47.62 gallons of fuel.

The approximate cost of fuel for your trip is between $119.05 and $166.67.

===============   End Trip Summary   ==================

Please input your car's average miles per gallon (enter 0 to quit) >> 18

Please tell me the range of fuel costs you expect to pay (per gallon).

The lowest per gallon cost of fuel is >> 2.50

The highest per gallon cost of fuel is >> 3.50

Please tell me how many miles you plan to travel >> 1000

===============   Trip Summary   ==================

You will need to purchase 55.56 gallons of fuel.

The approximate cost of fuel for your trip is between $138.89 and $194.44.

===============   End Trip Summary   ==================

Please input your car's average miles per gallon (enter 0 to quit) >> 0

Thank you, please drive safely and have a nice trip!

Functions Assignment Instructions

Starter stub tripStarter.c

FUNCTIONS ASSIGNMENT

Design and implement an interactive program named trip.c that collects information about the user's car and planned travel, and reports back useful information.

The dialog below shows exactly what data should be collected as input and reported as output.

Some Hints to get started

/* Not tested not complete code

   Just to get you started

*/

#include <stdio.h>

     /* FUNCTION PROTOTYES */

      void WelcomeMessage();

     void AskUserForInput(); /* ask and check whether user wants to continue

                                                 if wants to continue gather information

                                                and calculate the results (optional create more functions)

                                             */

     void PrintTripSummary(float fuel, float minCost, float maxCost, float travelMiles);

                                           /* could call this from AskUserForInput();

                                                 In a loop and feed it the user input

                                            */

    /* MAIN */

     int main() {

        /* Call the functions */

         return 0;

}

You do not need to verify user input data. Presume that the user enters reasonable/correct data.

Although you might want to test the results of entering "interesting data" such as alpha data instead of numeric.

Below is the program output.  Blue is used to illustrate the output, while regular text shows user Input.

Welcome to the Trip Planner!

So you are ready to take a trip? Let me help you plan for

your fuels costs and required stops to fill up your tank.

============================================================

Please provide answers to the prompts below and I will

display a summary for you when I have computed the results.

============================================================

Please input your car's average miles per gallon (enter 0 to quit) >> 21

Please tell me the range of fuel costs you expect to pay (per gallon).

The lowest per gallon cost of fuel is >> 2.50

The highest per gallon cost of fuel is >> 3.50

Please tell me how many miles you plan to travel >> 1000

===============   Trip Summary   ==================

You will need to purchase 47.62 gallons of fuel.

The approximate cost of fuel for your trip is between $119.05 and $166.67.

===============   End Trip Summary   ==================

Please input your car's average miles per gallon (enter 0 to quit) >> 18

Please tell me the range of fuel costs you expect to pay (per gallon).

The lowest per gallon cost of fuel is >> 2.50

The highest per gallon cost of fuel is >> 3.50

Please tell me how many miles you plan to travel >> 1000

===============   Trip Summary   ==================

You will need to purchase 55.56 gallons of fuel.

The approximate cost of fuel for your trip is between $138.89 and $194.44.

===============   End Trip Summary   ==================

Please input your car's average miles per gallon (enter 0 to quit) >> 0

Thank you, please drive safely and have a nice trip!

Explanation / Answer

total fuel needed= (total miles to travel / mileage)

minimum fuel cost required= minimum fuel cost per gallon * total fuel needed

maximum fuel cost required= maximum fuel cost per gallon * total fuel needed

The code is written below.

//trip.c

#include<stdio.h>

void WelcomeMessage(){

    printf("So you are ready to take a trip??? Let me help you plan foryour fuels costs and required stops to fill up your tank.");

    printf(" Please provide answers to the prompts below and I will display a summary for you when I have computed the results");

    printf(" ==========================================================");

   

}

void PrintTripSummary(float mileage,float minCost,float maxCost,float travelMiles){

    float fuel_needed=travelMiles/mileage;

    float min=fuel_needed*minCost;

    float max=fuel_needed*maxCost;

    printf(" ==================TRIP SUMMARY========================");

    printf(" You will need to purchase %.2f gallons of fuel",fuel_needed);

    printf(" The approximate cost of fuel for your trip is between $%.2f and $%.2f",min,max);

    printf(" ===============END OF TRIP SUMMARY====================");

}

void AskUserForInput(){

    float mileage,minCost,maxCost,travelMiles;

    printf(" Please input your car's average miles per gallon (enter 0 to quit): ");

    scanf("%f",&mileage);

    if(mileage==0){

        printf(" Thank you, please drive safely and have a nice trip!");

    }else{

        printf(" Please tell me the range of fuel costs you expect to pay (per gallon).");

        printf(" The lowest per gallon cost of fuel is :");

        scanf("%f",&minCost);

        printf(" The highest per gallon cost of fuel is :");

        scanf("%f",&maxCost);

        printf(" Please tell me how many miles you plan to travel: ");

        scanf("%f",&travelMiles);

        PrintTripSummary(mileage,minCost,maxCost,travelMiles);

        AskUserForInput();

       

    }

}

int main() {

   WelcomeMessage();

   AskUserForInput();

   return 0;

}

//Output

So you are ready to take a trip???

Let me help you plan for your fuels costs and required stops to fill up your tank.

Please provide answers to the prompts below

and I will display a summary for you when I have computed the results

==========================================================

Please input your car's average miles per gallon (enter 0 to quit): 21

Please tell me the range of fuel costs you expect to pay (per gallon).

The lowest per gallon cost of fuel is :2.5

The highest per gallon cost of fuel is :3.5

Please tell me how many miles you plan to travel: 1000

==================TRIP SUMMARY========================

You will need to purchase 47.62 gallons of fuel

The approximate cost of fuel for your trip is between $119.05 and $166.67

===============END OF TRIP SUMMARY====================

Please input your car's average miles per gallon (enter 0 to quit): 18

Please tell me the range of fuel costs you expect to pay (per gallon).

The lowest per gallon cost of fuel is :2.5

The highest per gallon cost of fuel is :3.5

Please tell me how many miles you plan to travel: 1000

==================TRIP SUMMARY========================

You will need to purchase 55.56 gallons of fuel

The approximate cost of fuel for your trip is between $138.89 and $194.44

===============END OF TRIP SUMMARY====================

Please input your car's average miles per gallon (enter 0 to quit):0

Thank you, please drive safely and have a nice trip!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote