Question: In c + + String dataFileName and double onionQuantity are read from input. Open dataFileName as an output file. If the file fails to open:

In c++
String dataFileName and double onionQuantity are read from input. Open dataFileName as an output file. If the file fails to open:
Use cout to output dataFileName followed by ": file-open operation failure" and a newline.
Terminate the program with 1 as the return value without writing to the file.
Otherwise, write onionQuantity followed by "kilograms of onions" and a newline to the opened file.
Ex: If the input is note. txt 20.5, then note.txt contains:
20.5 kilograms of onions
In c + + String dataFileName and double

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!