Program that determines of a set of rental cars

Assignment Help Basic Computer Science
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).

Reference no: EM13765025

Questions Cloud

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.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd