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 1E

a.

Program Plan Intro

Program Plan:

  1. Include library files for various operations.
  2. Declare object of ifstream.
  3. Create a statement to open the given file “prices.dat”.
  4. Use if statement with fail() method to check that the entered file name is available or not.
  5. Use while loop to read the file.
  6. int main() function is used to perform all the task.
  7. Display the calculated results to the user.

Program Description: The main purpose of the program is to read data from thegiven file “prices.dat”, and to display the file data to the user.

b.

Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare object of ifstream.
  • Create a statement to open the given file “prices.dat”.
  • Use if statement with fail() method to check that the entered file name is available or not.
  • Use while loop to read the file.
  • int main() function is used to perform all the task.
  • Display the calculated results to the user.

Program Description: The main purpose of the program is to modify the program code given in part (a) so that the program use !inFile.eof() instead of the expression inFile.good().

Blurred answer
Students have asked these similar questions
(Racing car) Write a program that simulates car racing, as shown in Figure 9.29b– d. The car moves from left to right. When it reaches the right end, it restarts from the left and continues the same process. Let the user increase and decrease the car’s speed by pressing the Up and Down arrow keys.Figure 9.29(a) The programs display a fan and (b–c) a moving car. (d) You can redraw a car with a new base point. Use Python
(PYTHON) (Display characters) Write a function that prints characters using the following header: def printChars(ch1, ch2, numberPerLine): This function prints the characters between ch1 and ch2 with the specified numbers per line. Write a test program that prints ten characters per line from 1 to Z.
(Numerical) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters to 0, and then generate a large number of pseudorandom integers between 0 and 9. each time a 0 occurs, increment the variable you have designated as the zero counter; when a 1 occurs increment the counter variable that's keeping count of the 1s that occur; and so on. finally display the number of 0s, 1s, 2s, and so on that occurred and the percentage of the time they occurred.
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