Programming Assignment#2 Car-Pool Savings Calculator Solution




  1. Research several car-pooling websites.
  2. Write an application named MyCarPool2 that calculates your daily driving cost, so that you can estimate how much money could be saved by car-pooling, which also has other advantages such as reducing carbon emission and reducing traffic congestion. The application should input the following information and display the user’s cost per day of driving to work with and without car-pooling.
    1. Total miles driven per day.
    2. Cost per gallon of gasoline.
    3. Average miles per gallon.
    4. Parking fees per day.
    5. Tolls per day.
    6. Number of passengers (sharing the same vehicle).
  • Compute the saving per day (divide daily cost by the number of passengers), week (5 days), month (22 days), and year (260 days) if you car-pool with the number of passengers entered above.


  1. Use System.out.printf statements to print your output.
  2. Include in your program output a report header with your name, class and section, and current date.
  3. Include appropriate labels, indentions, and alignments.
  • Make sure you document your class and code.
  • Attach (do not turn in any hardcopy) via BlazeView the following items:
    1. A single typed page with your name, class, date, and program title. The report (named MyReport2) should include what you learned from the programming assignment, problems faced, skills learned, and your observations.
    2. Name the class that contains the main method (MyCarPool2).

Attach NOT MyCarPool2.class

  1. Zip all your files into single one. Name it with your last name followed by the program#.

For example, Fares2

  1. Make sure that your program is well documented and readable.
  2. The output is well labeled and aligned

Sample input

Welcome to the Daily Driving Cost calculator
Enter the number of miles you drive per day: 25
Enter the cost per gallon of gas (ie., 2.25): 2.45
Enter average miles per gallon of gas: 21.5
Enter the parking fees per day: 5.5
Enter the tolls per day : 1.75
Enter the passengers: 3

Sample output

****************** Car Pooling Report **************************
Name:          John Smith
Course:        CS1301
Date:           8/28/2015

Daily Miles Driven:                     25
Cost per gallon:                           2.45
Average Miles Per Gallon:          21.50
Parking fees:                                 5.50
Toll cost:                                       1.75
Number Of Passengers:                3

One Passenger Daily Cost:           10.10
Daily Savings:                                 6.73
Weekly Savings:                           33.66
Monthly Savings:                        148.12
Annual Savings:                          1750.47

****************** Have a nice day **************************

error: Content is protected !!