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
State whether the following are true or false. If the answer is false, explain why.c) The expression (x > y && a < b) is true if either x > y is true or a < b is true.
Also test the function in main
For each of the following statements, state whether it is True or False.
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning