Group exercises - chapter 2

Mr. Gottsacker
Computer Programming


Electric vehicle cost calculator

This project is designed for groups of two people.


Part 1: Gas-powered vehicle trip cost calculator

Write a program called GasPoweredTripCalculator.java that collects the following information from the user about a gas-powered vehicle:

Compute the cost of driving that trip's distance, and output the result to the user.

Part 2: Electric vehicle trip cost calculator

Electric vehicles require a less straightforward method for computing the cost of one trip. Instead of miles per gallon, EVs have a mileage per battery charge. To arrive at cost per trip, this means you first have to figure out how much it costs to charge a battery, and then determine how much of the battery is spent on each trip. Each EV battery holds a number of kilowatt-hours (kWh). To calculate how much it costs to charge a battery, you can multiply the battery's kilowatt-hours capacity by the cost of a kilowatt-hour. Then, you can divide the result by the EV's mileage to determine how much it costs to drive the EV one mile.

Note: The cost of one kilowatt-hour is usually around $0.10 in the United States.

Write a program called ElectricTripCalculator.java that collects the following information from the user about an electric vehicle:

Compute the cost of driving that trip's distance, and output the result to the user.

Part 3: Analysis

Suppose you are considering buying a new Rivian truck. With a fully charged 105 kWh battery, it can travel 230 miles. It costs $69,000. Use the Java programs you wrote to determine whether buying the Rivian is a good idea as a replacement for your gas-powered car. Compute the cost of a typical trip using each of the vehicles. Will the price of the Rivian ever pay for itself? In other words, will the savings from the Rivian on each trip eventually cover the price of the new vehicle? If so, after how many miles? After how many trips? You may write another Java program or simply use a calculator to compute how many trips it would take to cover the cost.

To complete this task, you should keep the following things in mind:

Project report

Put the details of your project in a report format. This report can be in a .txt file, Google Doc, or some other portable document format. Whenever you use the Internet to find information, include a link to the source of that information. Your report should contain the following information:

  1. Requirements specification
    1. State the project's requirements for each part, as you understand them.
  2. System analysis
    1. What are the system's inputs? Include information about your gas-powered car, the price of gas, the price of electricity, and the length of your trip.
    2. What are the system's outputs?
    3. What formulas will you use to obtain the outputs?
  3. System design
    1. Describe the breakdown of subsystems. Which programs are being used to solve which problems?
    2. Describe your strategy and algorithm for reaching the conclusion desired in Analysis.
  4. Testing
    1. How do you know the program works? Describe any test cases used for the first two programs. These can be simple, with input values that are easy to verify.
    2. Consider using values from this article as ground truth.
  5. Analysis results
    1. Will the Rivian's all-electric design make up for its price?
    2. If so, how many miles will it take? How many trips?
    3. What limitations does your software have? Are there any other less tangible considerations you should take into account that could offset the price of the Rivian (e.g., environmental impact)?


Project submission

I will share a Google Drive folder titled with the last names of the group members. Upload your GasPoweredTripCalculator.java file, ElectricTripCalculator.java file, and Project Report file directly into that folder.