Exercise 4. Create a data file in the same directory as program Frame2, and name it Frame.in. Make the values in the file consistent with the input statements. Run program Frame2. Show the contents in your Frame.in file and the output of your program Exercise 5.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 2PP: (Data processing) a. Store the following data in a file, or use the numbers.dat file provided on...
icon
Related questions
Question
100%
Can anyone help me with these questions
3. File I/O
Enter the following program
Create a new project called Frame2 (use the same configuration
to your project as Frame2.cpp. Use this program for exercises 4-5.
// Program Frame2 reads input values that represent the dimensions
// of a print from a file and calculate the amount of wood needed for
// the frame.
tinclude <iostream>
#include <fstream>
Using namespace std;
int main ()
ifstream inFile;
inFile.open("Frame.in");
// Vertical dimension in inches
// Horizontal dimension in inches
// Inches of wood needed
int side;
int top;
int inchesOfWood;
inFile >> side >> top;
cout << "Dimensions are " << side << " and "
« top << "." « endl:
inchesofWood = top + top + side + side;
cout << "You need " <« inchesOfWood
<< " inches of wood." << endl;
return 0;
}
Exercise 4.
Create a data file in the same directory as program Frame2, and name it Frame.in. Make the values in
the file consistent with the input statements. Run program Frame2. Show the contents in your Frame.in
file and the output of your program
Exercise 5.
Change program Frame2 so that the output goes to a file named Frame.out. You must perform the
following tasks:
- Declare outFile to be of type ofstream.
- Invoke function open to associate the internal name outFile and the external name Frame.out.
- Send the output to steam outFile.
Include your code and the contents of the files Frame.in and Frame.out
Transcribed Image Text:3. File I/O Enter the following program Create a new project called Frame2 (use the same configuration to your project as Frame2.cpp. Use this program for exercises 4-5. // Program Frame2 reads input values that represent the dimensions // of a print from a file and calculate the amount of wood needed for // the frame. tinclude <iostream> #include <fstream> Using namespace std; int main () ifstream inFile; inFile.open("Frame.in"); // Vertical dimension in inches // Horizontal dimension in inches // Inches of wood needed int side; int top; int inchesOfWood; inFile >> side >> top; cout << "Dimensions are " << side << " and " « top << "." « endl: inchesofWood = top + top + side + side; cout << "You need " <« inchesOfWood << " inches of wood." << endl; return 0; } Exercise 4. Create a data file in the same directory as program Frame2, and name it Frame.in. Make the values in the file consistent with the input statements. Run program Frame2. Show the contents in your Frame.in file and the output of your program Exercise 5. Change program Frame2 so that the output goes to a file named Frame.out. You must perform the following tasks: - Declare outFile to be of type ofstream. - Invoke function open to associate the internal name outFile and the external name Frame.out. - Send the output to steam outFile. Include your code and the contents of the files Frame.in and Frame.out
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 5 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr