Answered step by step
Verified Expert Solution
Question
1 Approved Answer
M2-P2-data2Read.dat file at this link: https://drive.google.com/open?id=12lsiw3rjK4Ug_hUYCpVpuo8YWev6t5yi This problem uses the data file M2-P2-data2Read.dat' that can be downloaded from Canvas. The file contains an unknown number
M2-P2-data2Read.dat file at this link:
https://drive.google.com/open?id=12lsiw3rjK4Ug_hUYCpVpuo8YWev6t5yi
This problem uses the data file "M2-P2-data2Read.dat' that can be downloaded from Canvas. The file contains an unknown number of lines, each with one word w and 2 numbers x and V Write a C++ program that does the following (a) (6 points) Ask for a file name from which data will be read, giving the option to enter "def" to use a default value (b) (4 points) Test the value entered to see if "def" was entered. If so, use "M2-P2 (c) (10 points) Count the number of lines in the data file; if you are unable to get it, (d) (15 points) Read the provided data file one line at a time, and process the data data2Read.dat" as the default filename; use 100 from here on: on each line according to the value of w as follows if w is "add", calcuate r+y if w is "sub", calculate r -y y o if w is "mult", calculate r . if w is "div", calculate r/y if by any chance you are unable to read the file, set values for w, xr and y and make sure to include the if statements that will perform the correct operation; (e) (10 points) Print the result for each line in a file, one value per line; (f) (5 points) in addition, for the first 10 lines of data, print to screen the operation performed: for example, if line 4 was "mult 4.0 1.5", print "line 4: 4.0*1.5=6.0" This problem uses the data file "M2-P2-data2Read.dat' that can be downloaded from Canvas. The file contains an unknown number of lines, each with one word w and 2 numbers x and V Write a C++ program that does the following (a) (6 points) Ask for a file name from which data will be read, giving the option to enter "def" to use a default value (b) (4 points) Test the value entered to see if "def" was entered. If so, use "M2-P2 (c) (10 points) Count the number of lines in the data file; if you are unable to get it, (d) (15 points) Read the provided data file one line at a time, and process the data data2Read.dat" as the default filename; use 100 from here on: on each line according to the value of w as follows if w is "add", calcuate r+y if w is "sub", calculate r -y y o if w is "mult", calculate r . if w is "div", calculate r/y if by any chance you are unable to read the file, set values for w, xr and y and make sure to include the if statements that will perform the correct operation; (e) (10 points) Print the result for each line in a file, one value per line; (f) (5 points) in addition, for the first 10 lines of data, print to screen the operation performed: for example, if line 4 was "mult 4.0 1.5", print "line 4: 4.0*1.5=6.0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started