Programming assignment - car cost calculator calculate the


Programming Assignment - Car Cost Calculator

Data will be read in from a file - Make sure you include code to ensure the file exists before reading the data.  If the input file does not exist print an error message and end the program.

The data on the file contains:

  • Year -int
  • VIN -string
  • Make - string
  • Model-string
  • Annual Mileage-int
  • Annual Insurance Premium-double
  • Annual Maintance-double
  • Average Miles/gallon

Sample Data File

2000

22332222222

Ford

Mustang

10000

1000.00

670.00

33

2016

2233443422

Toyota

Prius

1000

500.00

355.00

40

2015

1122334455

Toyota

Rav4

12000

1200.00

560.00

21

Calculate the annual cost of owning the car. 

The following costs will be calculated

Cost of Gas (Ask user to enter in the average price /gallon) - Use this to calculate the gas cost for all cars.

How much money was spent of gas:

Divide the Annual Miles / MPG  - Gives you the gallons of gas used in a year

Multiply gallons of gas * gas cost per gallon

Total Annual Cost will be calculated as follows

Gas cost for the year + Insurance Premium +maintenance

Create a report that should be printed on the console with the following header followed by the details of each car.  Your file should contain at least 5 cars.

Car Make Car Model  Car Year  Annual Insurance cost  Annual Gas Cost  Total Cost

In addition you should also create a disk file. 

-Ask the user to enter the name of the output file to be created.

-Use that name to open the file.

-The file should contain the VIN number for each car as well as the total cost of annual ownership for that car.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Programming assignment - car cost calculator calculate the
Reference No:- TGS02261367

Expected delivery within 24 Hours