Search for over 100,000 study notes and past assignments!
Download study resources by swapping your own or buying Exchange Credits.
Study from your library anywhere, anytime.
10 Pages • Essays / Projects • Year: Pre-2020
The Problem Declare a structure of type Car to represent a motor car including the elements: make (string, ie either an array of chars or a pointer to a char) manufactureDate (Date - see below) purchaseDate (Date - see below) purchasePrice (double) You will need to also declare a structure of type Date to represent the: day (int) month (int) year (int) (That is, you will have structures nested inside a structure.) Write a program that reads (from the user or a file - the user is given a choice) the above car information for a number of cars. Put this in an array called fleet that can hold up to 10 cars. (The program is to be able to handle a fleet of less than 10 cars as well. You may like to use a sentental value for this purpose.) The program can give the user the following options: add a car; delete last car (ie the last car on the array); display the fleet on the screen; save the fleet to a file; read the fleet from a file. You are not expected to be able to originally create the file externally to your program (ie you can only read it after you have saved it from your program). You are free to use either a binary or text file (hint: binary files are much easier). Write the following input functions: addCar() and getDate() (which gets the information from the user) and readFleet() (which reads the information from a file). (You are to use the "pass-by-reference" rather than the "return" mechanism for these functions.) Write the following output functions: showFleet(), showCar(), showDate(), (which prints the information to the screen) and saveFleet() (which saves the information to a file). Note that the purchase price is to have a '$' sign before the amount and the amount is to be printed to two decimal places. Both the getDate() and showDate() functions should be generic enough to handle both the manufactureDate and purchaseDate. Your program is to have appropriate error checking for user input and file I/O. That is, for user input, you need to check that the dates (ie day, month, and year) and purchase price are within an appropriate range. For the file I/O you need to check for fopen() returning a NULL pointer. You do not have to check for type mismatching.
This document is 20 Exchange Credits
More about this document:
This document has been hand checked
Every document on Thinkswap has been carefully hand checked to make sure it's correctly described and categorised. No more browsing through piles of irrelevant study resources.
This is an Essay / Project
Essays / Projects are typically greater than 5 pages in length and are assessments that have been previously submitted by a student for academic grading.
What are Exchange Credits?
Exchange Credits represent the worth of each document on Thinkswap. In exchange for uploading documents you will receive Exchange Credits. These credits can then be used to download other documents for free.
We want you to be satisfied with your learning, that’s why all documents on Thinkswap are covered by our Satisfaction Guarantee. If a document is not of an acceptable quality or the document was incorrectly described or categorised, we will provide a full refund of Exchange Credits so that you can get another document. For more information please read Thinkswap's Satisfaction Guarantee.
Studying with Academic Integrity
Studying from past student work is an amazing way to learn and research, however you must always act with academic integrity.
This document is the prior work of another student. Thinkswap has partnered with Turnitin to ensure students cannot copy directly from our resources. Understand how to responsibly use this work by visiting ‘Using Thinkswap resources correctly’.
Claim a Bounty
Similar documents to "Assignment 2" avaliable on Thinkswap
Documents similar to "Assignment 2" are suggested based on similar topic fingerprints from a variety of other Thinkswap Subjects