Project: Fuel Efficiency (Version 2)

Fuel Efficiency

Automobile exhaust is a major contributor to air pollution. According to the Union of Concerned Scientists, personal vehicles contribute nearly one-fifth of U.S. emissions [1]. In order to reduce the amount of emissions, more fuel efficient cars are being developed. Fuel efficient cars can also save drivers money at the gas pump, or even eliminate gas costs altogether.

There are many different types of technology being developed to improve fuel efficiency, including hybrid gas/electric, hydrogen fuel cells, biodiesel, and solar. You might ask the question, are these types of cars really “cleaner” than traditional gasoline-only cars? This video discusses this question:

For this problem, you will compare the fuel efficiency for gas-only cars vs. hybrid cars. A car’s fuel efficiency is measured in how many miles can be driven per gallon of gas (mpg).

C++ Project: Automobile Fuel Efficiency

This project will provide you with an introduction to the fundamentals of problem-solving in C++. The focus of this project is on how to solve simple problems using C++ data types, variables, and input/output operations. In this project, you will…

  • Develop code to read data from the standard input and produce data to the standard output.
  • Translate a given mathematical expression into equivalent syntactically correct programming statements.
  • Write code that conforms to a programming style specified by the instructor.

Create a program called FuelEfficiency.cpp. Use the following table to help complete the three parts of the assignment. Copy and paste the table into a word processing document:

Car Type MPG Gallons used over 100,000 miles Cost of gas over lifetime at $2.50/gallon Cost of gas over lifetime at $4.00/gallon
Sedan: gas-only
Sedan: hybrid
SUV: gas-only
SUV: hybrid

 

Part 1: Follow these steps to determine the amount of gas used and money spent on gas for each type of car:

  • Declare variables to store the mpg for each car (gas and hybrid). This will result in two (2) variable declarations.
  • Declare a constant called GAS_PRICE and assign it the value of 2.50.
  • Prompt the user to input the mpg for gas and hybrid, and store the values the user inputs into your variables.
  • Declare variables to store the gallons of gas used for each car (gas and hybrid). This will result in two (2) variable declarations.
  • Calculate how many gallons of gas will be used by each type of car over a sample lifetime of 100,000 miles.
  • Declare variables to store how much money will be spent on gas over the lifetime of each car (gas and hybrid). This will result in two (2) variable declarations.
  • Calculate how much money will be spent on gas over the lifetime of the car.
  • Output all of the calculated values with descriptive messages.
  • When you run the program, input these test values:
    • Gas-only:  30 mpg
    • Hybrid:  45 mpg

    and enter the data output by the program in the table above.

Part 2: Assume that the previous mpg values were for a sedan. Next, we will look at the gas/money savings for an SUV. Run your program again and test it with the following mpg input values:

  • Gas-only:  20 mpg
  • Hybrid: 30 mpg

Enter the data in the table above.

Part 3: Next, change the cost of a gallon of gas (GAS_PRICE) from $2.50 to $4.00, re-run the tests from Parts 1 and 2, and review the results. How much more savings is there for the hybrid sedan and SUV over their gas-only counterparts?

Deliverables

See the instructor for submission instructions and due date(s).

Footnotes

[1] http://www.ucsusa.org/clean-vehicles/car-emissions-and-global-warming

Project created by Tricia Clark (tkc3@psu.edu).

Powered by WordPress. Designed by WooThemes

Skip to toolbar