Question

In: Electrical Engineering

Design and implement an interactive program named trip.c that collects information about the user's car and...

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

/* FUNCTION PROTOTYPES */

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. Black 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 fuel 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) >> 16

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

The lowest per gallon cost of fuel is >> 4.17

The highest per gallon cost of fuel is >> 5.20

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

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

You will need to purchase approximately 56 gallons of fuel.

The approximate cost of fuel for your trip is between $235 and $293

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

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

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

The lowest per gallon cost of fuel is >> 4.17

The highest per gallon cost of fuel is >> 5.20

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

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

You will need to purchase approximately 118 gallons of fuel.

The approximate cost of fuel for your trip is between $493 and $615

=============== 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!

Solutions

Expert Solution

#include<stdio.h>

#include<math.h>

#include<stdlib.h>

void welcomeMessage();

void AskUserForInput();

void printtripsum(float,float,float,float);

void welcomeMessage()

{

printf("Welcome to the Trip Planner!\nSo you are ready to take a trip?\nLet me help your plan for your fuel costs and required stops to fill up your tank.\n");

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

}

void AskUserForInput()

{

float fuel,minCost,maxCost,travelMiles;

int ch;

while(1)

{

printf("Enter 0 to quit\nelse enter anything\n");

scanf("%d",&ch);

switch(ch)

{

case 0:

exit(1);

default:

printf("Please input your car's average miles per gallon\n");

scanf("%f",&fuel);

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

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

scanf("%f",&minCost);

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

scanf("%f",&maxCost);

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

scanf("%f",&travelMiles);

printtripsum(fuel,minCost,maxCost,travelMiles);

}

}

}

void printtripsum(float fuel,float minCost,float maxCost,float travelMiles)

{

printf("Trip Summary\n");

int c=round(travelMiles/fuel);

printf("You will need to purchase approximately%dgallons of fuel\n",c);

int d=round(minCost*(travelMiles/fuel));

int e=round(maxCost*(travelMiles/fuel));

printf("The approximate cost of fuel for your trip is between $%dand$%d\n",d,e);

printf("End trip summary.\n");

}

int main()

{

welcomeMessage();

AskUserForInput();

return 0;

}


Related Solutions

In this programming assignment, you will implement a SimpleWebGet program for non- interactive download of files...
In this programming assignment, you will implement a SimpleWebGet program for non- interactive download of files from the Internet. This program is very similar to wget utility in Unix/Linux environment.The synopsis of SimpleWebGet is: java SimpleWebGet URL. The URL could be either a valid link on the Internet, e.g., www.asu.edu/index.html, or gaia.cs.umass.edu/wireshark-labs/alice.txt or an invalid link, e.g., www.asu.edu/inde.html. ww.asu.edu/inde.html. The output of SimpleWebGet for valid links should be the same as wget utility in Linux, except the progress line highlighted...
This is C# programming. In Chapter 2, you created an interactive application named GreenvilleRevenue. The program...
This is C# programming. In Chapter 2, you created an interactive application named GreenvilleRevenue. The program prompts a user for the number of contestants entered in this year’s and last year’s Greenville Idol competition, and then it displays the revenue expected for this year’s competition if each contestant pays a $25 entrance fee. The programs also display a statement that compares the number of contestants each year. Now, replace that statement with one of the following messages: If the competition...
Design a PLC ladder logic program to implement an automatic Car-Wash process. The system should have...
Design a PLC ladder logic program to implement an automatic Car-Wash process. The system should have a start and stop pushbuttons. When a Car enters the washing skid, a load cell switch is activated and the following sequence is performed automatically: 1. Soaping for (20) sec through soap nozzles 2. Washing for (120) sec using big brushes 3. Rinsing for (60) sec using water nozzles 4. Drying for (40) sec using air nozzles After finishing this process, the washing skid...
c# In Chapter 2, you created an interactive application named MarshallsRevenue. The program prompts a user...
c# In Chapter 2, you created an interactive application named MarshallsRevenue. The program prompts a user for the number of interior and exterior murals scheduled to be painted during the next month by Marshall’s Murals. Next, the programs compute the expected revenue for each type of mural when interior murals cost $500 each and exterior murals cost $750 each. The application also displays the total expected revenue and a statement that indicates whether more interior murals are scheduled than exterior...
Design a program in Java to display the following: Car Design Enter the car model's year:...
Design a program in Java to display the following: Car Design Enter the car model's year: 1957 Enter the car's make: Chevy The model year is 1957 The make is Chevy The speed is 0 Let's see what it can do!! The speed is,... 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 STOP! STOP! Let me OUT! The...
Design a program in Java to display the following: Car Design Enter the car model's year:...
Design a program in Java to display the following: Car Design Enter the car model's year: 1957 Enter the car's make: Chevy The model year is 1957 The make is Chevy The speed is 0 Let's see what it can do!! The speed is,... 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 STOP! STOP! Let me OUT! The...
Write a java program using the information given Design a class named Pet, which should have...
Write a java program using the information given Design a class named Pet, which should have the following fields (i.e. instance variables):  name - The name field holds the name of a pet (a String type)  type - The type field holds the type of animal that a pet is (a String type). Example values are “Dog”, “Cat”, and “Bird”.  age - The age field holds the pet’s age (an int type) Include accessor methods (i.e. get...
Car Rental Management System in C++ The aim of this project is to design and implement...
Car Rental Management System in C++ The aim of this project is to design and implement a computerized Car Rental Management System for a company called COEN244Cars. The company rents two types of cars: standard and luxury cars. A car is identified by a car identification number (int), a type (string), and a flag that indicates whether the car is currently available or not. The company distinguishes between three types of customers: regular customers, corporate customers, and VIPs (Very Important...
In java design and code a class named comparableTriangle that extends Triangle and implements Comparable. Implement...
In java design and code a class named comparableTriangle that extends Triangle and implements Comparable. Implement the compareTo method to compare the triangles on the basis of similarity. Draw the UML diagram for your classes. Write a Driver class (class which instantiates the comparableTriangle objects) to determine if two instances of ComparableTriangle objects are similar (sample output below). It should prompt the user to enter the 3 sides of each triangle and then display whether or not the are similar...
TestLibrary.java Design and implement a class named Book. A book has a serial number, a title,...
TestLibrary.java Design and implement a class named Book. A book has a serial number, a title, an author, and a publisher. Create appropriate constructor(s) and accessor and mutator methods for the Book class. Add a static variable to the Book class and set its initial value to 100000000. When a new book is created, this static variable is automatically incremented by 1 and the new value is assigned as the serial number of the new book. Design and implement a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT