Declare a structure of type "Car" to represent a motor car including the elements:
(a) make (string)
(b) model (string)
(c) odometer (int)
(d) manufactureDate (Date - see below)
(e) purchaseDate (Date - see below)
(f) petrolTank, capacity and current level (Tank - see below)
You will need to also declare a structure of type "Date" to represent the:
(a) day (int)
(b) month (int)
(c) year (int)
You will need to also declare a structure of type "Tank" to represent the:
(a) capacity (double)
(b) currentLevel (double)
(That is, you will have structures nested inside structures.)
Write a program that reads (from the user or a file) the car information for a fleet of cars. Put this in an array called "Fleet" that can hold up to 10 cars. (The user and file input must be able to handle less than 10 cars as well.) The program is then to give the user the option of either displaying the fleet on the screen or saving it to a file.
Write the following input functions: "getFleet", "getCar", "getDate", "getTank" (which gets the information from the user) and "readFleet" (which reads the information from a file).
Write the following output functions: "showFleet", "showCar", "showDate", "showTank" (which prints the information to the screen) and "saveFleet" (which saves the information to a file).
Your program is to have appropriate error checking for user input and file I/O.
I don't really know what to do....this is what I've done so far..I hate C...
#include <stdio.h>
#include <string.h>
#define STRSIZE 50
#define SIZE_OF_FLEET 10
typedef struct {
int day;
int month;
int year;
} Date;
typedef struct {
double capacity;
double currentLevel;
} Tank;
typedef struct {
char make[STRSIZE];
char model[STRSIZE];
int odometer;
Date manufactureDate; /* structure within struct */
Date purchaseDate; /* structure within struct */
Tank petrolTank, capacity, currentLevel; /* structure within struct */
} Car;
void getCar(Car *pCar);
void getFleet(Car paramfleet[]);
void getTank(Tank *pTank);
int main(void)
{
getCar(&Car);
return 0;
}
void getFleet(Car paramfleet[])
{
}
void getCar(Car *pCar)
{
printf("Enter the make of the car.\n");
scanf("%s", &(*pCar).make[STRSIZE]);
printf("Enter the model of the car.\n");
scanf("%s", &(*pCar).model[STRSIZE]);
printf("Enter the odometer number");
scanf("%d", &(*pCar).odometer);
}
void getTank(Tank *pTank)
{
/* pTank->capacity; */
}