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

  Write strategies for personnel of security organization

Write down 1,400- to 2,100-word paper in which you write strategies for personnel of security organization. The main factors in work environment which should be addressed in new department

  Find final contents of cache using direct-mapped cache

Suppose direct-mapped cache with 16 one-word blocks that is initially empty, label each reference in list as hit or miss and find final contents of the cache.

  Program that accepts 10 integers and determines and prints

write a program that accepts 10 integers and determines and prints the smallest and largest integer input by the user. Your program should use at least the following four variable

  Show the set of positive powers

Let S show the set of positive powers of 3 , i.e. S = {3, 9, 27, 81,...}. Find if S and N(Natural Numbers) are equipotent. Justify your answer.

  How many times will the job be interrupted

how many times will the job be interrupted and on which queue will it finish its execution?

  Cameras and scanners being used in some medical offices

How are digital cameras and scanners being used in some medical offices? Can you think of some additional or innovative uses for these device in a medical office?

  Implement a simple automated bank registry system

Implement a simple automated bank registry system. The implementation will include several attributes related to a transaction, and the data will be managed in a global linked list within memory.

  Information security management and framework choice

What are the major perspectives to consider in information security management and framework choice

  The device consists of three lights lined up in a row

A friend would like you to build an "electronic eye" for use as a fake security device. The device consists of three lights lined up in a row, controlled by the outputs Left, Middle, and Right, which, if asserted, indicate that a light should b..

  Possibilities curve between health and all other goods

Draw a production possibilities curve between health and all other goods

  Facebook and privacy issues

Smartphones and Teenagers • Facebook and Privacy Issues • Challenges of Sport Organisations in Australia

  Converting binary numbers in decimal

Convert the given binary numbers in decimal: 101110; 1110101; and 110110100. Convert the given decimal numbers to bases indicated.

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