C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
Question
Book Icon
Chapter 8.2, Problem 8E

(a)

Program Plan Intro

To create a file named as car.dat and insert the given data without the headings.

(b)

Program Plan Intro

Program plan: -

  • Import header file and use namespace for standard I/O.
  • Define the main function.
  • Create the object of ifstream class and opening the file.
  • Declare the variables.
  • Use the while-loop to iterateover the file to read the content.
  • Display the header.
  • Calculate the mpg.
  • Increment the value of total cars after reading each line.
  • Calculate the total Miles Driven the total Gallons Used.
  • Display the total Miles Driven, total Gallons Used, and then calculate and display the average gallons used.

Program description: -

The main purpose of the program is to read the data of the file created in exercise 8a and display the car number, miles driven, gallons of gas used, and miles per gallon. Also, calculate and display the total miles driven, total gallons used and the average mpg for all cars.

Blurred answer
Students have asked these similar questions
Instructions(C++) A company hired 10 temporary workers who are paid hourly and you are given a data file that contains the last name of the employees, the number of hours each employee worked in a week, and the hourly pay rate of each employee. You are asked to write a program that computes each employee’s weekly pay and the average salary of all employees. The program then outputs the weekly pay of each employee, the average weekly pay, and the names of all the employees whose pay is greater than or equal to the average pay. If the number of hours worked in a week is more than 40, then the pay rate for the hours over 40 is 1.5 times the regular hourly rate. Use two parallel arrays: a one-dimensional array to store the names of all the employees (Name) a two-dimensional array of 10 rows and 3 columns to store the number of hours an employee worked in a week (Hrs Worked), the hourly pay rate (Pay Rate), and the weekly pay (Salary). Your program must contain at least the following…
Huffman Code[Problem Description]For an English article, the frequency of occurrence of 26 lowercase letters is counted, and then they are encoded by Hoffman code.[Basic Requirements]1)      Read the original text file from the file and display the text on the screen..2)      Output the number of occurrences of 26 English lowercase letters, and the corresponding Hoffman code... Below is the data to be displayed  At present, most of the dynamic sign language recognition is only for sign language words,the continuous sign language sentence recognition research and the corresponding results are less, because the segmentation of such sentence is very difficult. In this paper, a sign languagesentence recognition algorithm is proposed based on weighted key frames. Key frames can be regardedas the basic unit of sign word, therefore, according to the key frames we can get related vocabularies, and thus we can further organize these vocabularies into meaningful sentence. Such work can avoid the…
(C ONLY) The program expects the name of an input file and an output file to be given by the user. If the user does not input any names, default file names should be used, such as input.txt and output.txt. The input files have lines which look like this: 3 Tester College; 1909 33001 The first number represents the rank; it is followed by the school name, year founded, and approximate number of students. Read the list of colleges into an array of structures. You may assume that the maximum size of a college name string is 64. The program should use either the insertion sort algorithm or the selection sort algorithm to sort the array in descending order by rank. Display any k consecutive schools requested by the user. For instance, if the user enters 12, the program displays the first 2 schools in a readable format of your choice. If the user enters 15, the program displays the first five schools, if the user enters 2 7, display 7 schools beginning with the one at index 1 (2 - 1), and so…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education