Question: Double melonQuantity and string friendName are read from input. An ofstream named outFS is declared and the file named melon.txt is opened. Write the following

Double melonQuantity and string friendName are read from input. An ofstream named outFS is declared and the file named melon.txt is opened. Write the following to the opened file: "To buy:" followed by a newline melonQuantity followed by " kilograms of melons for ", friendName, and a newline Ex: If the input is 17.5 Maryam, then melon.txt contains: To buy: 17.5 kilograms of melons for Maryam

#include #include using namespace std;

int main() { ofstream outFS; double melonQuantity; string friendName;

cin >> melonQuantity; cin >> friendName; outFS.open("melon.txt"); if (!outFS.is_open()) { cout << "melon.txt" << " could not be opened." << endl; return 1; } /* Your code goes here */ outFS.close(); return 0; }

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 Databases Questions!