// TestB.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include using namespace std; const int NUMCARS = 8; struct Car { int fuelType; double price; }; int CalculateTax(int fuelType); int main() { double totalCarCost = 0; Car cars[NUMCARS] = { {0, 10000}, {2, 8500}, {0, 22000}, {1, 14000}, {1, 37000}, {2, 18900}, {1, 28000}, {0, 45000} }; cout << "Car Price \t Fuel Type \t Tax" << endl; for(int i = 0; i < NUMCARS; i++) { Car car = cars[i]; int tax = CalculateTax(car.fuelType); cout << car.price << "\t\t" << car.fuelType << "\t\t" << tax << endl; totalCarCost += car.price; } cout << "Total car cost = " << totalCarCost << endl; return 0; } int CalculateTax(int fuelType) { switch(fuelType) { case 0: return 50; case 1: return 60; default: return 0; } }