Okay, so I'm trying to write a code that calculates the registration fee of different vehicles based on a given criteria. I'm supposed to write outside functions and read the data from in file while using the eof() function. Here is what I have so far, but I'm all sorts of confused. Any tips?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
double basefee(string x, double y);
string brand, model, type;
char vin;
double year, fee, weight;
int main()
{
ifstream inFile;
inFile.open("VehicleInput.txt");
while (!inFile.eof())
{
inFile >> vin >> brand >> model >> year >> type >> weight;
double basefee();
cout << basefee();
}
return 0;
}
// different criteria for base fee based on type of vehicle
double basefee(string x, double y)
{
int fee;
switch (string type)
{
case 'car':
fee = 100
break;
case 'suv':
fee = 100;
break;
case 'bus':
fee = 200;
break;
case 'truck':
fee = 500;
break;
default:
fee = 0;
break;
}
}
|
The input file has the following information:
VIN number brand model year type weight
AB54H77HG553DHJ8J8 TOYOTA CAMRY 2008 CAR
C745D4S78SSSWERDDF NISSAN PATHFINDER 2014 SUV
WAGGT345ADFGGGS234 ATLANTIC EXPRESS 2013 BUS
LKU338NGTH0988J77H KENWORTH T800 2009 TRUCK 20000
TNNH75RDG88J0R6669 FORD FOCUS 2005 CAR
Here are the instructions I was given for the code:
Write an application in C++ that calculates the vehicle registration fee.
Rules for fee calculation:
All vehicles will have a VIN number, make, model, and year. Trucks will also have weight as the input.
All new cars and SUVs will have a base fee of $100.00, buses will have a base fee of $200.00, and trucks will have a base fee of $500.00.
Trucks above 12,000 LBS will have a surcharge of 22% added to the base fee. This will make up the new base fee for the trucks above 12,000 LBS.
Depending upon the age of the vehicle, base fee will be reduced by 10% for each year up to a maximum of 7 years. For example if the year of the vehicle is 2015, then base fee will reduce by 50% (2020 – 2015 = 5 Years and 10% for every year).
There is a 6.5% tax added to the base fee.
There is $2.00 additional highway fund that is added to the fee.