Reference no: EM13765025
For this assignment you will write a program that determines which of a set of rental cars the user can rent for a user-specified rental rate. The rental car data is contained in a text file which will be fed into your program using stdin redirection (or a pipe, as you prefer).
Your submission should follow the instructions for program organization and Moodle
Your program must be written entirely using pointer syntax; i.e., it cannot contain any []'s
Your program must meet the following requirements:
1. The input file of rental car data will have the following format:
a. The first line will consist of the number of cars in the file.
b. Each line after the first will consist of a single car record, formatted as follows:
model Name year rental Rate
2. Define a Car structure type in your header file. The Car structure should have three fields: a model (a string), a year (an integer), and a daily rental rate (a floating point number). The model field string will be dynamically allocated (see function 3(b) below).
3. Your program should define the following functions:
a. A function that takes a single Car argument. The function should output the fields of the Car in a sentence. The rate should be formatted as money.
b. A function that takes a single Car argument. The function should first dynamically allocate the Car model field large enough to hold a string of at most 50 characters in length. It should then use scanf to read the next line from stdin and place the values into the appropriate fields in the Car argument. The function should return 0 if successful and 1 if an error occurred in reading the line. This function should not perform any output.
c. A function that takes as arguments an array of cars and the number of cars that array can hold. The function should fill the array with the indicated number of cars using calls to your function 3(b). The function should perform reasonable error checking and should return 0 if successful and 1 if an error occurred. This function should not perform any output.
d. A function that takes as arguments an array of cars, the number of cars in the array, and a desired rental rate. The function should print-out all cars in the array with a rental rate less than or equal to the specified rate, calling your function 3(a) to perform any car output.
4. Your main function should do the following:
a. Your program should take one command line argument which represents the desired rental rate.
b. Dynamically allocate an array of Cars exactly large enough to hold the number of cars in the input file.
c. Fill the array with cars from stdin by calling your function 3(c). If an error occurs give an informative error message and exit the program with a status value of 1.
d. Call your function 3(d) with the desired rental rate (specified as a command line
argument).
Run your program three times with a command line argument rental rate of $50.00, and redirecting stdin (or piping) from the rental car data files cars1.txt, cars2.txt, and cars3.txt. These files are available in /usr/local/cs367/cars.tar.gz on cs367.sou.edu (hint: one or more of these input files may contain an intentional error that should cause your program to exit with an appropriate error message during input processing).
How much new long-term debt financing will be needed
: At year-end 2013, Wallace Landscaping’s total assets were $1.8 million and its accounts payable were $450,000. Sales, which in 2013 were $2.1 million, are expected to increase by 20% in 2014. Total assets and accounts payable are proportional to sale..
|
Determine one opportunity regarding use of social media
: Determine one challenge and one opportunity regarding the use of social media in public administration communications. Provide a rationale for your response.
|
What is the value of preferred stock
: Ezzell Corporation issued preferred stock with a stated dividend of 10 percent of par. Preferred stock of this type currently yields 8 percent, and the par value is $100. Assume dividends are paid annually. What is the value of Ezzell's preferred sto..
|
Channels of communication in criminal justice
: The process of verbal and nonverbal communication and the associated components of each Differences between listening and hearing in communication The formal and informal channels of communication in criminal justice organizations
|
Program that determines of a set of rental cars
: For this assignment you will write a program that determines which of a set of rental cars the user can rent for a user-specified rental rate.
|
Considering the purchase of an outstanding kramerko bond
: It is now march 1, 2001 and you are considering the purchase of an outstanding Kramerko bond with a par value of $1000 that was issued March 1, 1999. the Kreamerko bond has a 9.5 percent annual coupon and a 30-year original maturity (it matures on Fe..
|
Write a paper on the topic racism in music
: Write a 5 page paper or 1500 words on the topic Racism in Music. Use the bibliography attached below and any other relevant sources as may deem useful.
|
Problems that affect supply chain management success
: What do you consider are some of the problems that affect supply chain management success?
|
Issues related to types of data
: Discuss concepts by focusing on two implications for, and examples of, marketing oneself, marketing in social media, or other up-to-date online sources.
|