Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions