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

  Find newton interpolating polynomial for the function

Find Newton%u2019s interpolating polynomial for the function ;

  Create worksheet using excel having different columns

Create a worksheet using excel having different columns depicting the Serial Number, Name of the Student, Marks obtained in various subjects i.e. English, Maths, and Science.

  Needs to examine and process the string

Needs to examine and process the string

  Use a for loop to iterate through the array and input values

Use a For loop to iterate through the array and input the values.

  Calculate the first n amount of terms of following sequence

if given x0=5, x1=2 and xi=(2xi-1+ 2xi-2) use c++ to calculate the first n amount of terms of this sequence. Using only recursion

  What is the output of the following loop

What is the output of the following loop

  These processes compete to use the computers

a modern personal computer or workstation executes many simultaneous processes. these processes compete to use the

  You task is to break the code and there is more than one

many people are interested in codes especially in our computer world. we can create a simple code by assigning digits

  Apply the tools and techniques in research and analysis

Project objective: 1.Apply the tools and techniques in research and analysis required to evaluate computer and information science products. 2.Describe how pipelining and superscalar processing improve the speed at which a computer program is execute..

  The dba at premiere products

The DBA at Premiere Products wants you to investigate biometric

  Discuss what settings are often changeable via the keyboard

1. Discuss what settings are often changeable via the keyboard on a notebook, such as volume, screen brightness, and Bluetooth and/or Wi-Fi.2. The touchpad device should be the laptop's primary pointing device, but other options are the TrackPoin..

  C++ statements that define the function grade

At Enlightened State University, students earn grades of Honors, Pass, or Fail rather than usual letter grade. The function grade returns H, P, F depending on whether avg merits a grade of Honors.

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